Please find the code below.. I am sure it must be a very small error
add_action( 'rest_api_init', function() {
register_api_field( 'topic',
'post_parent',
array(
'get_callback' => 'slug_get_post_meta_cb',
//'update_callback' => 'slug_update_post_meta_cb',
'update_callback' => 'slug_update_spaceship2',
'schema' => null,
)
);
});
function slug_update_spaceship2( $value, $object, $field_name ) {
return update_post_meta( $object->ID, $field_name, $value);
}
function slug_get_post_meta_cb( $object, $field_name, $request ) {
return get_post_meta( $object['id'], $field_name );
}
@robkk I am a php developer myself but can you guide me on how can i achieve this ?