Skip to content

Instantly share code, notes, and snippets.

@scottopolis
Last active January 17, 2019 18:48
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 scottopolis/e6afd52def596805c05b1886e48af809 to your computer and use it in GitHub Desktop.
Save scottopolis/e6afd52def596805c05b1886e48af809 to your computer and use it in GitHub Desktop.
Events Calendar Pro to WP-API Post Format
<?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