-
-
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.
This file contains 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
/** | |
* 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