Hi All,
I searched for an easy way to display meta-box content created by Piklist in the rest_api response.
For example:
//Title: Custom meta to show in Rest
//Post Type: post
piklist( 'field', array(
'type' => 'text',
'field' => 'custom_text',
'label' => 'Custom text demo',
//'show_in_rest' => true, //not working :(
) );
I can use register_rest_field to add the meta to the api response ( for example : )
register_rest_field( 'post', 'cm', array(
'get_callback' => function ( $post ) {
return get_post_meta( $post['id'], 'custom_text', true );
},
'schema' => array(
'description' => __( 'Custom piklist text.' ),
'type' => 'string'
),
) );
and it does the trick, but it would be awesome if just passing 'show_in_rest' => true to the meta params make it automatically show in the response.