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

WordPress Trac noreply at wordpress.org
Mon Oct 29 16:34:50 UTC 2018


#45220: register_rest_field doesn't work
-------------------------------+------------------------------
 Reporter:  Dudo               |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  REST API           |     Version:  5.0
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by Dudo):

 seems like is working with this code

 {{{#!php
 <?php
 function yasr_rest_comment_meta() {

         register_rest_field(
                 'post',
                 'yasr_overall_rating',
                 array(
                         'get_callback' => 'yasr_rest_get_overall_rating',
                         'update_callback' => null,
                         'schema' => $overall_rating_schema,
                 )

         );

         $overall_rating_schema = array(
                 'description'   => 'Overall Rating for the post',
                 'type'          => 'string',
                 'context'       =>  array( 'view' )
         );

 }
 }}}


 I think the "schema" part needs more documentation.

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


More information about the wp-trac mailing list