Issues with meta name mapping
-
I have noticed two main issues with the ‘original’ and ‘custom’ meta key mapping.
1. After enabling the desired meta fields in the Dashboard, I am unable to edit the custom meta keys through the admin UI. These appear to be stored as null or empty string in the DB.
2. (More importantly) The meta keys appear in the REST feed for the CPT, but all values are null. Upon investigation I found that this is due to replacing dashes with underscores in the meta key name to return in JSON. If I remove this string replacement from line 417 of class-wp-rest-api-controller.php it works as expected (as least as far as the returned JSON goes).
For the latter issue, I don’t believe that simply translating underscores back to dashes at the point of lookup (e.g. custom_meta_data_callback) will work since you wouldn’t know if the original meta key contained underscores. A better approach may be to store the underscored key as the ‘custom key’ by default.
- The topic ‘Issues with meta name mapping’ is closed to new replies.