Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created February 19, 2013 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenharris/4988415 to your computer and use it in GitHub Desktop.
Save stephenharris/4988415 to your computer and use it in GitHub Desktop.
Get 'todays' event with Event Organiser. (Today means running today - might have started before today).
<?php
/**
* Returns today's event (or false if it one doesn't exist). If there is more than one it simply returns the first one.
* By 'today' I mean running today (though could have started earlier). You can change altering it slightly.
*
* @see http://wp-event-organiser.com/documentation/function/eo_get_events/
*
*/
function sh_get_todays_event(){
//Get events running today
$events = eo_get_events( array(
'event_start_before' => 'today',
'event_end_after' => 'today',
'numberposts' => 1,
));
if( !$events ){
//If no events, just return false
return;
}else{
return array_pop( $events);
}
}
/*
* Usage:
*
* global $post; //This stuff is needed for the title/content!
*
* if( $post = sh_get_todays_event() ){
*
* setup_postdata(); //Needed for the content!
*
* echo '<h3>'.get_the_title().'</h3>';
*
* the_content();
*
* //Clean up after ourselves
* wp_reset_postdata();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment