You’ll want to use the field and the post type. You’ll add the following to your functions.php
add_action( 'rest_api_init', function () {
register_rest_field( '<post-type>', 'folder_path', array(
'get_callback' => function( $post_arr ) {
return get_post_meta( $post_arr['id'], 'folder_path', true );
},
) );
register_rest_field( '<post-type>', 'file_name', array(
'get_callback' => function( $post_arr ) {
return get_post_meta( $post_arr['id'], 'file_name', true );
},
) );
} );
- add’s fields to REST API
- change
<post-type>
to your specific post-type - set the field name for the API and return the actual field itself for it (in this specific case, I just left the field_name as the meta name)