Guest User

Untitled

a guest
Jun 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Set up a custom REST API controller class for the Page post type.
  5. *
  6. * @author Kellen Mace
  7. *
  8. * @param array $args The post type arguments.
  9. * @param string $name The name of the post type.
  10. *
  11. * @return array $args The post type arguments, possibly modified.
  12. */
  13. function km_set_custom_page_rest_controller( $args, $name ) {
  14. // If this post type's name is not 'page', do not modify its args.
  15. if ( 'page' !== $name ) {
  16. return $args;
  17. }
  18.  
  19. // Tell WordPress to use our KM_REST_Pages_Controller class
  20. // for Page REST API requests.
  21. $args['rest_controller_class'] = 'KM_REST_Pages_Controller';
  22.  
  23. return $args;
  24. }
  25. add_filter( 'register_post_type_args', 'km_set_custom_page_rest_controller', 10, 2 );
Add Comment
Please, Sign In to add comment