Skip to content

Instantly share code, notes, and snippets.

@jkudish
Created February 18, 2012 01:01
Show Gist options
  • Save jkudish/1856644 to your computer and use it in GitHub Desktop.
Save jkudish/1856644 to your computer and use it in GitHub Desktop.
This is an example of a query which gets a single random event from the 'featured' event category amongsts evetns from The Events Calendar
<?php
/**
* This is an example of a query which gets a single random event from the
* 'featured' event category amongsts evetns from The Events Calendar
*
* @see http://tri.be/support/forums/topic/random-featured-event-custom-widget/
*/
get_header();
$featured_query = new WP_Query();
$featured_query->query(array(
'post_type' => 'tribe_events',
'posts_per_page' => '1',
'orderby' => 'rand',
'eventDisplay' => 'upcoming',
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'featured',
'operator' => 'IN'
),
),
));
if ($featured_query->have_posts()) :
while ( $featured_query->have_posts() ) : $featured_query->the_post();
// show the event here with whatever function you need
die(var_dump($post));
endwhile;
endif;
get_footer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment