Created
February 18, 2012 01:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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