Custom fields in custom path in REST API response
-
Hello,
I have this issue as addressed here: https://stackoverflow.com/questions/57055013/how-to-nest-a-field-under-another-using-register-rest-field-in-wp-rest-api
So I would like to expose custom fields (eg. created by Advanced Custom Fields, or programmaticaly) to WP REST API. Thats OK, I can accomplish that with
register_rest_field
function, which also support array values (unlike register_meta function).But I can not figure out, how to display the fields under the
meta
field. They are always shown only in top-level node.So instead:
id: 1 meta: [] my_custom_field: "some value" my_another_custom_field: 0: "Alfa" 1: "Bravo" 2: "Charlie"
I need to expose them in this way:
id: 1 meta: my_custom_field: "some value" my_another_custom_field: 0: "Alfa" 1: "Bravo" 2: "Charlie"
Is there a way to do that?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Custom fields in custom path in REST API response’ is closed to new replies.