Skip to content

Instantly share code, notes, and snippets.

@jentheo
Last active October 17, 2017 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jentheo/1be5502370030a3d52061e3e751a5f4c to your computer and use it in GitHub Desktop.
Save jentheo/1be5502370030a3d52061e3e751a5f4c 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
) );
@polack45
Copy link

polack45 commented Oct 17, 2017

Hi,
Thanks for your code !
But i would like to add the category.
Do you have a issue ?
Thanks of lot.
See you bye

Here is my code :

`$events = tribe_get_events( array(

$args = array(
  'nopaging' => true,
  'post_type'=>'tribe_venue',
 
	  'meta_query' => array(
		array(
		   'key' => '_VenueCity',
		   'value' => array( 'Frankfurt'),
		   'compare' => 'IN'
		)),
		
	
		
		'tax_query' => array(
			array(
					'taxonomy' => TribeEvents::TAXONOMY,
					'post_status'=>'publish',
					'field' => 'id',
					'terms' => 'Sport'
			))

)));

$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
) );

if( $upcoming->have_posts()) :
while( $upcoming->have_posts() ): $upcoming->the_post();
echo '

' . $upcoming->post->post_title . '

';
endwhile;
wp_reset_postdata();
else :
echo 'No posts found';
endif;

die();

?>

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment