Skip to content

Instantly share code, notes, and snippets.

@TheHeat
Forked from stephenharris/upcoming-events.php
Last active December 18, 2015 02:19
Show Gist options
  • Save TheHeat/5710501 to your computer and use it in GitHub Desktop.
Save TheHeat/5710501 to your computer and use it in GitHub Desktop.
Display a list of upcoming events with Event Organiser http://wp-event-organiser.com/ without repeating instances of recurring events.
/**
* Display a list of upcoming events with Event Organiser without repeating instances of recurring events
**/
//Get upcoming events for the next 6 months
$events = eo_get_events(array(
'event_start_after'=>'today',
'event_end_after' =>'today',
'event_start_before' => '+6 month',
'showpastevents'=>true //Will be deprecated, but set it to true to play it safe.
));
//this is to collect event IDs that have been displayed
$seen = array();
if( $events ):
global $post;
foreach( $events as $post ):
setup_postdata($post);
$counter = $post->ID;
$format = ( eo_is_all_day() ? get_option('date_format') : get_option('date_format') . ' - ' . get_option('time_format') );
//if this is an event we haven't seen yet, let it through
if(!in_array($counter, $seen)): ?>
<article class="event">
<?php the_title(); ?>
<?php echo eo_get_the_start($format); ?>
<?php the_excerpt(); ?>
</article>
<?php //add this events ID to the $seen array
$seen[] = $counter;
endif;
endforeach;
wp_reset_postdata();
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment