Skip to content

Instantly share code, notes, and snippets.

@bitflower
Forked from CamdenSegal/custom-endpoints.php
Last active August 29, 2015 14:11
Show Gist options
  • Save bitflower/c270fb9c762b509a0f79 to your computer and use it in GitHub Desktop.
Save bitflower/c270fb9c762b509a0f79 to your computer and use it in GitHub Desktop.
class MAP_API_DemoItemType extends WP_JSON_CustomPostType {
protected $base = '/map/demo';
protected $type = 'demo';
public function register_routes( $routes ) {
$routes = parent::register_routes( $routes );
return $routes;
}
}
function map_api_init( $server ) {
global $map_api_demoitemtype;
$map_api_demoitemtype = new MAP_API_DemoItemType( $server );
add_filter( 'json_endpoints', array( $map_api_demoitemtype, 'register_routes' ) );
}
add_action( 'wp_json_server_before_serve', 'map_api_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment