Set up a custom WordPress REST API controller class for the Page post type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set up a custom REST API controller class for the Page post type. | |
* | |
* @author Kellen Mace | |
* | |
* @param array $args The post type arguments. | |
* @param string $name The name of the post type. | |
* | |
* @return array $args The post type arguments, possibly modified. | |
*/ | |
function km_set_custom_page_rest_controller( $args, $name ) { | |
// If this post type's name is not 'page', do not modify its args. | |
if ( 'page' !== $name ) { | |
return $args; | |
} | |
// Tell WordPress to use our KM_REST_Pages_Controller class | |
// for Page REST API requests. | |
$args['rest_controller_class'] = 'KM_REST_Pages_Controller'; | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'km_set_custom_page_rest_controller', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment