Skip to content

Instantly share code, notes, and snippets.

@ButlerFuqua
Created October 4, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ButlerFuqua/7aa691521078c7f341c9322ff9078137 to your computer and use it in GitHub Desktop.
Save ButlerFuqua/7aa691521078c7f341c9322ff9078137 to your computer and use it in GitHub Desktop.
/**
* Add REST API for BBPress
* /
* Thanks to Barry at https://bbpress.org/forums/topic/is-there-an-api-for-bbpress/
*/
function bbpress_enable_rest_api() {
$types = array(
bbp_get_reply_post_type(),
bbp_get_forum_post_type(),
bbp_get_topic_post_type(),
);
foreach ( $types as $slug ) {
$definition = (array) get_post_type_object( $slug );
$definition['show_in_rest'] = true;
$definition['rest_controller_class'] = 'WP_REST_Posts_Controller';
register_post_type( $slug, $definition );
}
}
add_action( 'bbp_register_post_types', 'bbpress_enable_rest_api', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment