Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
List upcoming events
/**
* Display a list of upcoming events with Event Organiser
*
* Snippet that produces a simple list of the next 5 upcoming events.
*/
//Get upcoming '
$events = eo_get_events(array(
'numberposts'=>5,
'event_start_after'=>'today',
'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe.
));
if( $events ){
global $post;
echo '<ul>';
foreach( $events as $post ){
setup_postdata($post);
?>
<li>
<a href='<?php the_permalink() ?>'> <h5><?php the_title(); ?></h5></a>
on <?php eo_get_the_start('jS F Y'); ?>
<p><?php the_excerpt(); ?></p>
</li>
<?php
}
echo '</ul>';
wp_reset_postdata();
}else{
echo 'No Upcoming Events';
}

rascode commented Feb 12, 2013

Thanks a lot for posting this. Was able to drop this in to feature the most recent events on the homepage of a project I'm currently working on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment