Last active
January 17, 2019 18:48
-
-
Save scottopolis/e6afd52def596805c05b1886e48af809 to your computer and use it in GitHub Desktop.
Events Calendar Pro to WP-API Post Format
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
<?php | |
/* | |
* Plugin Name: ECP to WP-API (Posts Controller) | |
* Plugin URI: http://scottbolinger.com | |
* Description: Add tribe_events post type to WP-API using the posts controller. | |
* Version: 0.1 | |
* Author: Scott Bolinger | |
* Author URI: http://scottbolinger.com | |
* | |
* @author Scott Bolinger | |
* @copyright Copyright (c) Scott Bolinger 2018 | |
* | |
*/ | |
add_filter( 'register_post_type_args', 'app_tribe_type_args', 10, 2 ); | |
function app_tribe_type_args( $args, $post_type ) { | |
if ( 'tribe_events' === $post_type ) { | |
$args['show_in_rest'] = true; | |
// Optionally customize the rest_base or rest_controller_class | |
$args['rest_base'] = 'tribe-events'; | |
$args['rest_controller_class'] = 'WP_REST_Posts_Controller'; | |
} | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment