Hello,
How to show event of current day first on my calendar when I click on a day? Now it shows events that are still going (example art exhibitions).
Thanks!

Jukka Varis
Hi Jukka,
Is the “Events on < day >” page? That will show all events running on that particular day. It’s possible with a few lines of code to show only events that start on that day (if tha is what you want).
Or in the Settings > Event Organiser > General you can opt to show only future events and to consider a currently running event as past. That will mean those long-running events will not appear after they have started.

Stephen Harris
Yes, I’d like to know that code to do the trick in my question. I’d like to have those long running events on day page but at the bottom.

Jukka Varis
This snippet will ensure that an event will only appear on the day page if it starts on that day (rather than is running at any point on that day as it currently is):
add_action( 'pre_get_posts', function( $query ) {
//If querying for all events starting on given date, set the date parameters
if ( $query->get( 'ondate' ) ) {
//Normalise date delimiter
$ondate_start = str_replace( '/', '-', $query->get( 'ondate' ) );
$ondate_end = str_replace( '/', '-', $query->get( 'ondate' ) );
$parts = count(explode('-',$ondate_start));
if( $parts == 1 && is_numeric($ondate_start) ){
//Numeric - interpret as year
$ondate_start .= '-01-01';
$ondate_end .= '-12-31';
}elseif( $parts == 2 ){
// 2012-01 format: interpret as month
$ondate_start .= '-01';
try{
$end = new DateTime($ondate_start);
$ondate_end = $end->format('Y-m-t');
}catch( Exception $e){
$query->set('ondate',false);
}
}
$query->set( 'post_type', 'event' );
$query->set( 'event_start_before', $ondate_end );
$query->set( 'event_start_after', $ondate_start );
}
}, 12, 1 );
If you wanted events running that day which started previously you would need to do a separate query for that.

Stephen Harris