I am trying to change the API to get events under a chosen Category.
I currently have this code to get a response for events between dates and then events between dates with a tag
function tribe_api_query( $query ) {
$events = tribe_get_events( array(
‘eventDisplay’ => $query[‘eventDisplay’],
‘start_date’ => $query[‘start_date’],
‘end_date’ => $query[‘end_date’],
‘tag’ => $query[‘tag’]
) );
if ( empty( $events ) ) {
return null;
}
return $events;
}
add_action( ‘rest_api_init’, function () {
register_rest_route( ‘tribe_events/v2’, ‘/events/(?P<eventDisplay>[a-z\-]+)/(?P<start_date>[a-z0-9\-]+)/(?P<end_date>[a-z0-9\-]+)/(?P<tag>[a-z\-]+)’, array(
‘methods’ => ‘GET’,
‘callback’ => ‘tribe_api_query’,
) );
} );
add_action( ‘rest_api_init’, function () {
register_rest_route( ‘tribe_events/v2’, ‘/events/(?P<eventDisplay>[a-z\-]+)/(?P<start_date>[a-z0-9\-]+)/(?P<end_date>[a-z0-9\-]+)’, array(
‘methods’ => ‘GET’,
‘callback’ => ‘tribe_api_query’,
) );
} );
I need to add another response to get events between dates with a category chosen. I cannot find documentation to add a category in a similar way i added tag.
Thanks in advance