[wp-trac] [WordPress Trac] #39803: REST API meta type not working properly for custom post types
WordPress Trac
noreply at wordpress.org
Tue Feb 7 05:40:30 UTC 2017
#39803: REST API meta type not working properly for custom post types
------------------------------------+------------------------------
Reporter: chriseverson | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses: rest-api
------------------------------------+------------------------------
Comment (by rheinardkorf):
@chriseverson I had this problem a couple of days ago. The patch will not
resolve the issue.
In the docs (here: https://developer.wordpress.org/rest-api/extending-the-
rest-api/modifying-responses/#working-with-meta-and-register_meta) you
will see in the comments that for custom post types the $object_type has
to be "post".
What was not documented until recently is that for meta to work is that
you need to enable `custom-fields` support for your post type. This can be
done by adding it to the "supports" array of your post type or by using
`add_theme_support()`. See this in the docs:
> Note that for meta fields registered on custom post types, the post type
must have custom-fields support.
It had me tearing my hair out, but the answer ended up being simple.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39803#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list