Querying Venues

Querying venues

The eo_get_venues() function allows you to query venues. It acts as wrapper for get_terms() and all the arguments are as listed there (except hide_empty defaults to false, and you do not need to set the taxonomy).

The list of arguments that can be passed to eo_get_venues() includes:

  • orderby – Default is ‘name’. Can be name, count, slug, city, state, country, postcode, address or distance (when used with a {@link http://wp-event-organiser.com/pro-features/event-venue-queries/ proximity-query})
  • order – ASC|DESC Default is ASC.
  • hide_empty – Default is 0 (false)
  • exclude – Default is an empty array. An array, comma- or space-delimited string of term ids to exclude from the return array. If ‘include’ is non-empty, ‘exclude’ is ignored.
  • include – Default is an empty array. An array, comma- or space-delimited string of term ids to include in the return array.
  • number – The maximum number of terms to return. Default is to return them all.
  • offset – The number by which to offset the terms query.
  • fields – Default is ‘all’, which returns an array of term objects. If ‘fields’ is ‘ids’ or ‘names’, returns an array of integers or strings, respectively.
  • slug – Returns terms whose “slug” matches this value. Default is empty string.
  • search – Returned terms’ names will contain the value of ‘search’,
  • case-insensitive. Default is an empty string.


$venues = eo_get_venues(); 
if( $venues ){
    echo '<ul>'; 
    foreach($venues as $venue): 
         $venue_id = (int) $venue->term_id;
              printf('<li> <a href="%s">%s</a>', eo_get_venue_link($venue_id), esc_html($venue->name));
    echo '</ul>';

Querying venues by meta data

Querying venues by meta data requires 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.

In Pro you can store venue information using venue custom fields, and you can query venues by that data using a meta_query argument. This is identical in form to post’s meta_query that you can use with WP_Query.


To retrieve venues matching certain custom fields criteria you can use the eo_get_venues() function with the meta_query argument:

 $venues = eo_get_venues( array( 'meta_query' => $venue_query ) );

where $venue_query is a 2-dimensional array. For example, to get all venues in Edinburgh:

 $venue_query = array(
       'key' => '_city',
       'value' => 'Edinburgh',
 $edinburgh_venues = eo_get_venues( array( 'meta_query' => $venue_query ) );

Each inner-array can contain the following

  • key (string) – Venue custom field key.
  • value (string|array) – Venue custom field value (Note: Array support is limited to a compare value of ‘IN’, ‘NOT IN’, ‘BETWEEN’, or ‘NOT BETWEEN’)
  • compare – how the query should match the key-value. Possible values are ‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘LIKE’, ‘NOT LIKE’, ‘IN’, ‘NOT IN’, ‘BETWEEN’, ‘NOT BETWEEN’. Default value is ‘=’.
  • type (string) – The custom field type. Possible values are ‘NUMERIC’, ‘BINARY’, ‘CHAR’, ‘DATE’, ‘DATETIME’, ‘DECIMAL’, ‘SIGNED’, ‘TIME’, ‘UNSIGNED’. Default value is ‘CHAR’.

Note: You can query any, and multiple, custom field keys. Venue address details are stored with the meta keys

  • _address
  • _city
  • _state
  • _postcode
  • _country
  • _lat
  • _lng


For instance to get venues which are not in Scotland:

 $venue_query = array(
       'key' => '_country',
       'value' => 'Scotland',
       'compare' => '!='
 $non_scottish_venues = eo_get_venues( array( 'meta_query' => $venue_query ) );

To get all venues in Edinburgh or Glasgow which have a bar

 $venue_query = array(
       'key' => '_city',
       'value' => array( 'Edinburgh', 'Glasgow' ),
       'compare' => 'IN'
       'key' => 'has_bar',
       'value' => 1,
 $venues = eo_get_venues( array( 'meta_query' => $venue_query ) );