• 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.

Viewing 1 replies (of 1 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @hgh001,

    Sorry for the delay; I was away last week.

    Are you using the latest version (1.4.1) of the REST API plugin?

    1. When editing the meta field name and saving it by hitting “Save Settings,” the field names aren’t changed at all? If you click the CPT’s endpoint URL that we provide on the admin UI, you aren’t seeing the renamed fields?

    2. Line 417 of class-wp-rest-api-controller.php, which calls the custom_meta_data_callback function is required for using custom meta field names. It seems like there is another issue going on that is preventing the custom meta field names from saving properly and is then breaking the returned JSON data.

    Do you have any other plugins that interact with the REST API? Also, I’d recommend upgrading to WordPress 4.8 (for, among other reasons, any mismatches in version make it harder for me to accurately test).

    Again, sorry for the delay,
    Kevin.

Viewing 1 replies (of 1 total)
  • The topic ‘Issues with meta name mapping’ is closed to new replies.