Skip to content

Instantly share code, notes, and snippets.

@polack45
Forked from jentheo/city-query.php
Created October 17, 2017 21:09
Show Gist options
  • Save polack45/f10fc9c06265f0adf8e1d318a971aabf to your computer and use it in GitHub Desktop.
Save polack45/f10fc9c06265f0adf8e1d318a971aabf to your computer and use it in GitHub Desktop.
Query only events in Frankfurt
<?php
//Retrieve venues that match query criteria
$args = array(
'nopaging' => true,
'post_type'=>'tribe_venue',
//Only query venues in Frankfurt
'meta_query' => array(
array(
'key' => '_VenueCity',
'value' => array( 'Frankfurt'),
'compare' => 'IN',
)
)
);
$city_venue = get_posts( $args );
$venue_ids = wp_list_pluck( $city_venue, 'ID' );
wp_reset_postdata();
$upcoming = new WP_Query( array(
'post_type' => Tribe__Events__Main::POSTTYPE,
'meta_query' => array(
array(
'key' => '_EventVenueID',
'value' => $venue_ids,
'compare' => 'IN',
)
),
'paged' => $paged
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment