Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('rest_api_init', function(){
- register_rest_field('myposttype', 'image_link',
- array(
- 'get_callback' => 'get_for_rest_meta',
- 'update_callback' => 'update_for_rest_meta',
- 'schema' => null,
- )
- );
- });
- function get_for_rest_meta($object, $field_name, $single=true) {
- return get_post_meta( $object['id'], $field_name);
- }
- "image_link": [
- "http://www.something.com/something"
- ]
- content:"Some content"
- image_link:"http://www.something.com/something"
- status:"publish"
- title:"Some title"
- function update_for_rest_meta(???) {
- ???
- }
Add Comment
Please, Sign In to add comment