Last active
October 13, 2015 08:08
-
-
Save stephenh1988/4165380 to your computer and use it in GitHub Desktop.
List upcoming events
This file contains hidden or 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 | |
* | |
* 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'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.