[wp-trac] [WordPress Trac] #49255: It is not possible to register field for settings endpoint.

WordPress Trac noreply at wordpress.org
Tue Jan 21 17:16:57 UTC 2020


#49255: It is not possible to register field for settings endpoint.
--------------------------+-----------------------
 Reporter:  vavra7        |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  REST API      |     Version:  4.7
 Severity:  normal        |  Resolution:  invalid
 Keywords:  needs-patch   |     Focuses:  rest-api
--------------------------+-----------------------

Comment (by vavra7):

 Aha, I see now!

 So this is what I need:

 {{{#!php
 <?php
 function register_custom_settings()
 {
         $args = array(
                 'type' => 'string',
                 'default' => get_option('show_on_front'),
                 'show_in_rest' => true,
         );
         register_setting('custom_settings', 'show_on_front', $args);

 }
 add_action('rest_api_init', 'register_custom_settings');

 }}}

 Thank you @TimothyBlynJacobs

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


More information about the wp-trac mailing list