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 | |
/** | |
* 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