Guest User

Untitled

a guest
Apr 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. add_action('rest_api_init', function(){
  2. register_rest_field('myposttype', 'image_link',
  3. array(
  4. 'get_callback' => 'get_for_rest_meta',
  5. 'update_callback' => 'update_for_rest_meta',
  6. 'schema' => null,
  7. )
  8. );
  9. });
  10.  
  11. function get_for_rest_meta($object, $field_name, $single=true) {
  12. return get_post_meta( $object['id'], $field_name);
  13. }
  14.  
  15. "image_link": [
  16. "http://www.something.com/something"
  17. ]
  18.  
  19. content:"Some content"
  20. image_link:"http://www.something.com/something"
  21. status:"publish"
  22. title:"Some title"
  23.  
  24. function update_for_rest_meta(???) {
  25. ???
  26. }
Add Comment
Please, Sign In to add comment