[wp-trac] [WordPress Trac] #45220: register_rest_field doesn't work

WordPress Trac noreply at wordpress.org
Sat Nov 17 00:38:19 UTC 2018


#45220: register_rest_field doesn't work
------------------------------------------+-----------------------
 Reporter:  Dudo                          |       Owner:  (none)
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  5.0
Component:  REST API                      |     Version:  5.0
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  rest-api
------------------------------------------+-----------------------
Changes (by danielbachhuber):

 * keywords:  reporter-feedback => needs-patch needs-unit-tests


Comment:

 I was able to reproduce this issue by registering a custom field like
 follows:

 {{{
 add_action( 'rest_api_init', function() {
         register_rest_field( 'post', 'test_field', array(
                 'get_callback' => function() {
                         return 'test_value';
                 },
                 'schema' => null,
         ) );
 });
 }}}


 In WP 4.9.8, the `test_field` attribute is present for `GET
 http://wptest.test/wp-json/wp/v2/posts/1`. In WP 5.0-beta5-43907, the
 `test_field` attribute is missing.

 Where did it go?!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45220#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list