Guest User

Untitled

a guest
Jul 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. [
  2. {
  3. code: "json_no_route",
  4. message: "No route was found matching the URL and request method"
  5. }
  6. ]
  7.  
  8. function get_post_details ($params)
  9. {
  10. $id = $_GET['id'];
  11. $meta_value = $_GET['meta_value'];
  12.  
  13. if(update_post_meta( $id, '_yoast_wpseo_redirect', $meta_value ))
  14. {
  15. $post['status'] = 'Successfully Updated';
  16. $post['flag'] = '1';
  17. }
  18. else
  19. {
  20. $post['status'] = 'Error';
  21. $post['flag'] = '0';
  22. }
  23.  
  24. if( empty( $post ) ){
  25. return null;
  26. }
  27.  
  28. return $post;
  29. }
  30.  
  31. // Register the rest route here.
  32.  
  33. add_action( 'rest_api_init', function () {
  34. register_rest_route( 'post_info', 'post',array(
  35.  
  36. 'methods' => 'GET',
  37. 'callback' => 'get_post_details'
  38.  
  39. ));
  40.  
  41. });
Add Comment
Please, Sign In to add comment