WP-API / docs-v2

Documentation for version 2 of the API
http://v2.wp-api.org
58 stars 76 forks source link

BBPress Endpoint #191

Closed kenshinman closed 7 years ago

kenshinman commented 7 years ago

Hi, please i would like to know if there is a bbPress endpoint available yet in this plugin. Thanks

websupporter commented 7 years ago

No, therre are no bbPress endpoints available, but you can enable to show the custom post types and taxonomies of bbPress, if you register them with show_in_rest => true.

I am not very familiar with bbPress and I do not know, if the developers plan to enable bbPress for the REST API in the future, but I had a quick look and I think the following code can help you:

<?php
    function bbpress_show_in_rest( $args ) {
        $args['show_in_rest'] = true;
        return $args;
    }

    add_filter( 'bbp_register_forum_post_type', 'bbpress_show_in_rest' );
    add_filter( 'bbp_register_topic_post_type', 'bbpress_show_in_rest' );
    add_filter( 'bbp_register_reply_post_type', 'bbpress_show_in_rest' );
gui-com-pt commented 7 years ago

Just to clarify something. Snippet from @websupporter allow you to add forum, topic and reply to the API with default endpoints, so they're accessed with default custom post types like http://peace.com/wp-json/wp/v2/forum

This is all you need for a typical CRUD app but you'll only be working with default fields. If you want to filter stick posts, get counters, etc it you should check the docs to extend the controller.

I'll have to do this at least for the topic custom type within a few weeks for a cordova app that's consuming WC as backend. If someone wants to help me we can write it OSS, just PM me and with a few hours we write it.

kadamwhite commented 7 years ago

I'm going to close this out as documentation around plugin's API capabilities or endpoints should live in the plugin's documentation, even for plugins so widely used as BBPress.