How to Show a List of Recurring Events (but not all events individually) with Events Calendar Pro
If you use Events Calendar Pro and you want to have a list of all recurring events, but not a list of each specific reoccurrence within each event, well here’s the code for you:
<?php $upcoming = new WP_Query();
$upcoming->query( array(
'post_type' => 'tribe_events',
'posts_per_page' => 10,
) );
$postids = Array();
if ($upcoming->have_posts()) :
while ($upcoming->have_posts()) :
$upcoming->the_post();
$thisid = get_the_ID();
if ( !in_array($thisid, $postids)) :
array_push( $postids, $thisid);
if( !tribe_is_recurring_event() ) continue; ?>
<article class="event-snippet <?php $terms_as_text = strip_tags( get_the_term_list( $all_events->post->ID, 'tribe_events_cat', '', ' ', '' ) ); echo $terms_as_text; ?>">
<a href="<?php the_permalink(); ?>">
<h1><?php the_title(); ?></h1>
<p><?php echo tribe_get_recurrence_text(); ?><br/>
</a>
</article>
<?php endif; endwhile; endif; ?>
To be clear, let’s say you have three reoccurring events for a baseball league’s calendar: Practice, Games and Meetings. You want to have a list of all three of those events, but not a list of each and every occurrence of each event, this code does the trick.
Up Next: How to Include Password Protected Pages in WordPress Search Results