Adding show_in_rest = true to the Venues post type

Home Forums Additional Help Translations Adding show_in_rest = true to the Venues post type

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1020202
    Joe
    Guest

    Hi,

    I am using the WP REST API V2 to create endpoints so that we can access event data for use in a mobile app. I was successfully able to add show_in_rest = true to the tribe_events and tribe_organizer post types using this function and adding it to my functions.php file. That gave me access to the post type information. For some reason if I try using that function for the tribe_venue post type it does not work. I think it is getting overridden in the plugin for some reason. For now I made the cardinal sin of adding it to the code in the the-events-calendar/src/Tribe/Main.php file but I would like to know if there is any way that I could use a similar function that won’t be overridden. Do you know what my be causing it to not work for venues but to work for events and organizers?

    /**
    * Add REST API support to an already registered post type.
    */
    add_action( ‘init’, ‘organizer_rest_support’, 25 );
    function organizer_rest_support() {
    global $wp_post_types;

    //be sure to set this to the name of your post type!
    $post_type_name = ‘tribe_organizer’;
    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’;
    }
    }

    #1020340
    Nico
    Member

    Hey Joe,

    Thanks for reaching out here! Unfortunately we cannot provide support in our pre-sales forum, as the name indicates it’s only for pre-sales related inquiries.

    We are happy to assist our premium users with support issues via our premium forums. If you have not purchased one of our premium plugins, you can post in our open source forum.

    Regarding the issue you expose here I don’t see any reason why the venue post type should behave in a different why from the others, but it would be necessary to perform some tests and review the code. Maybe using a higher priority for the action? Not sure and as I stated I cannot extend on this here.

    Thanks,
    Nico

    #1030787
    Nico
    Member

    Hi there,

    It has been a while since my last post… I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Adding show_in_rest = true to the Venues post type’ is closed to new replies.