I'm new to the wp-api
. I'm trying to fetch some data that is being generated by a plugin.
in my case is a booking plugin named Hotelier
. I'v understood that from version 2 of the api you need to specify the show_in_rest = true
.
I'v followed this Article, but with no luck after trying to add the code to functions.php and even create a simple plugin.
- Do I need to add the code from the article in
function.php
or register a newplugin
- the Autor of the plugin mentioned the data is stored in
meta boxes
does it make any difference?
any tips here please, cheers to all
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 = ‘rooms’;
if( isset( $wp_post_types[ $post_type_name ] ) ) {
$wp_post_types[$post_type_name]->show_in_rest = true;
// Optionally customize the rest_base or controller class
$wp_post_types[$post_type_name]->rest_base = $post_type_name;
$wp_post_types[$post_type_name]->rest_controller_class = ‘WP_REST_Posts_Controller’;
}
}