An event is a post of type ‘event’, and a venue is a taxonomy-term of the taxonomy event-venue
. The venue ID is (in fact) the term ID. As such you can use the tax_query
arguments to query events by venue.
Sometimes you’ll want to perform a more advanced query by retrieving events which are at venues matching a specific venue query. Venue meta data queries are covered in Querying Venues. In this page we demonstrate how you can query events by those venue queries.
Event-venue queries require Event Organiser Pro to be installed alongside Event Organiser. If you haven’t done so already, you can purchase Pro here: wp-event-organiser.com/pricing
To retrieve events whose venue match a given query, Simply use the venue_query
argument (which behaves very similarly to WordPress’ native meta_query
argument ).
For instance to get all future events in the city of Edinburgh:
$edinburgh_events = new WP_Query( array(
'post_type' => 'event',
'venue_query' => array(
array(
'key' => '_city',
'value' => 'Edinburgh'
)
),
'event_start_after' => 'today'
));
Note: the venue query will also work with eo_get_events()
and get_posts()
.