Created
October 4, 2019 10:01
-
-
Save ButlerFuqua/7aa691521078c7f341c9322ff9078137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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