Changes between Initial Version and Version 1 of Ticket #40408, comment 4
- Timestamp:
- 04/21/2017 12:16:27 PM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #40408, comment 4
initial v1 1 1 it seems to me that the expected process works only with standard posts. In case of custom post types (marked as show_in_rest => true) with proper register_meta (marked as show_in_rest => true as well), it doesnt work if you rely on standard PostsController. In Its constructor it instantiates an WP_REST_Post_Meta_Fields object with proper post_type. However, since method get_meta_type returns "post" instead of proper post_type, get_registered_meta_keys returns wrong values when called by WP_REST_Meta_Fields::get_registered_fields. If WP_REST_Post_Meta_Fields::get_meta_type returned post type as passed in the contructor, everything would have worked... 2 3 EDIT: however, if WP_REST_Post_Meta_Fields::get_meta_type is overwritten to return the custom post type it then breaks the get_value method, which relies on get_meta_type for retrieving the actual value with get_metadata( $this->get_meta_type(), $object_id, $meta_key, false ); 4 5 To me, it seems that using the same method for both fetching the register fields for post type and getting their value is not correct, since values are always retrieved as post_meta whatever the actual type is, while definition of meta is post_type sensitive.