Daniel’s first answer should work – the default setting for the shortcode is to display all events. But you can use the showpastevents
attribute and set it to false.
That said – rather than using showpastevents
I’d encourage you to use event_start_after
or event_end_after
and set it to ‘now’ (depending on whether you want to include ‘running’ events). I’ll eventually depreciate showpastevents as the arguments/attributes event_start_after
,event_end_after
, event_start_before
, event_end_before
all accept relative date formats. (These are available in eo_get_events()
and has attributes in [eo_events]
).
Iamharian, here’s what I would do:
$event_args = array(
'numberposts' => 5,
'orderby' => 'eventstart',
'order' => 'ASC',
'event_end_after' => 'today',
);
$events = eo_get_events($event_args);
if ($events):
$return= '';
global $post;
$temp = $post;
foreach ($events as $post):
<?php echo get_the_post_thumbnail(get_the_ID(), 'large'); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-meta">
<!-- Choose a different date format depending on whether we want to include time -->
<?php if(eo_is_all_day()): ?>
<!-- Event is all day -->
<?php $date_format = 'F jS, Y'; ?>
<?php else: ?>
<!-- Event is not all day - include time in format -->
<?php $date_format = 'F jS, Y g:ia'; ?>
<?php endif; ?>
<?php printf(__('<h2>%s</h2>','eventorganiser'), eo_get_the_start($date_format) );?>
<?php if(eo_reoccurs()):?>
<!-- Event reoccurs - is there a next occurrence? -->
<?php $next = eo_get_next_occurrence($date_format);?>
<?php if($next): ?>
<!-- If the event is occurring again in the future, display the date -->
<?php printf(__('This event is running from %1$s until %2$s. The next chance to catch it at Fred's is %3$s','eventorganiser'), eo_get_schedule_start('F jS, Y'), eo_get_schedule_last('F jS, Y'), $next);?>
<?php else: ?>
<!-- Otherwise the event has finished (no more occurrences) -->
<?php printf(__('This event finished on %s','eventorganiser'), eo_get_schedule_last('F d, Y',''));?>
<?php endif; ?>
<?php else: ?>
<!-- Event is a single event -->
<?php endif; ?>
</div><!-- .entry-meta -->
endforeach;
//Reset post variable
$post = $temp;
endif;