Created
November 20, 2017 15:25
-
-
Save onnimonni/6b81eea074dad2c58902fad8174c7835 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Add REST API support to an already registered post type. | |
*/ | |
add_action( 'init', 'rata_post_type_rest_support', 25 ); | |
function rata_post_type_rest_support() { | |
global $wp_post_types; | |
// Be sure to set this to the name of your post type! | |
$post_type_name = 'rata'; | |
if( isset( $wp_post_types[ $post_type_name ] ) ) { | |
$wp_post_types[$post_type_name]->show_in_rest = true; | |
$wp_post_types[$post_type_name]->rest_base = $post_type_name; | |
$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment