jade99 Posted January 19, 2018 Share Posted January 19, 2018 I'm using this code successfully for one custom post type (CPT). I need to declare multiple CPT's. How do I code this? Additional post types I want to declare: bible3 worship-help library-book /** * Add REST API support to an already registered post type. */ add_action( 'init', 'my_custom_post_type_rest_support', 25 ); function my_custom_post_type_rest_support() { global $wp_post_types; //be sure to set this to the name of your post type! $post_type_name = 'planet'; 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'; } } Link to comment Share on other sites More sharing options...
ginerjm Posted January 19, 2018 Share Posted January 19, 2018 Other than have a variable using that name, what the h... IS a 'custom post type'? Link to comment Share on other sites More sharing options...
taquitosensei Posted January 19, 2018 Share Posted January 19, 2018 Other than have a variable using that name, what the h... IS a 'custom post type'? It's a wordpress post. Not $_POST. Here's the wordpress page on how to register post types. https://codex.wordpress.org/Post_Types Link to comment Share on other sites More sharing options...
ginerjm Posted January 19, 2018 Share Posted January 19, 2018 Once again - a poster should probably mention WORDPRESS when they post in here? Link to comment Share on other sites More sharing options...
maxxd Posted January 22, 2018 Share Posted January 22, 2018 Use the register_post_type() function for any and all post types you're creating. Make sure 'show_in_rest' is set to true in the arguments to make the data available via the WP rest api. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.