I am trying to register a custom setting field in my WordPress dashboard using the following code:
function register_fields()
{
register_setting('general', 'live_streaming_url', array(
'show_in_rest' => true,
'type' => 'string',
'default' => 'public',
));
add_settings_field('live_streaming_url', '<label for="live_streaming_url">'.__('Live
Streaming Link' , 'live_streaming_url' ).'</label>' , 'print_custom_field', 'general');
}
function print_custom_field()
{
$value = get_option( 'live_streaming_url', '' );
echo '<input type="text" id="live_streaming_url" name="live_streaming_url" style="width:250px;" value="' . $value . '" />';
}
add_filter('admin_init', 'register_fields');
The fields is working perfectly on the dashboard but it's not showing in the REST API when I call
http://MY_DOMAIN_NAME/wp-json/wp/v2/settings
Note: All the other fields are returned in the API expect that custom one.
Note: I am using WordPress 5.3.2