I’m registering a brand new area in my customized put up kind utilizing register_rest_field.
However I’m unable so as to add/replace the sector utilizing the remainder API of put up add/edit. Nonetheless, the get_callback operate is working superb.
The pattern code is just like the under –
register_rest_field('my_post_type', 'my_field', [
'get_callback' => function ($params) {
return get_post_meta($params['id'], 'my_field', true);
},
'update_callback' => operate ($worth, $object){
return update_post_meta($object->ID, 'my_field', $worth);
},
'schema' => [
'description' => __( 'Array of the ids', 'textdomain' ),
'type' => 'array',
'items' => [ 'type' => 'integer' ],
],
]);
Thanks prematurely!