Popular Categories
How to get featured events from Event Calendar?
If you wanted to highlight, promote, or feature a specific event on your site, The WordPress Events Calendar’s “Featured Events” are very useful. Making an event “Featured” imbues it with a number of special properties that make it stand out from non-featured events. Hence, when developing a custom WordPress theme one of the very requirements will be on how to handle these featured events and how to query them.
Well here is a snippet of code that can help you achieve this.
<?php $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; ?>
The above code will return a random single featured event. You can use this code within the theme files or even in templates.