Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Created February 15, 2016 16:54
Show Gist options
  • Save cliffordp/fc9b2df3c4d7cf062fde to your computer and use it in GitHub Desktop.
Save cliffordp/fc9b2df3c4d7cf062fde to your computer and use it in GitHub Desktop.
In month view, display all-day events below non-all-day events in each individual day cell.
<?php
/**
* In month view, display all-day events below non-all-day events in each individual day cell.
*
* Barry wrote it 2016-02-15
* https://gist.github.com/cliffordp/fc9b2df3c4d7cf062fde
*
* See https://gist.github.com/cliffordp/4a273f419457d8862bb0 for similar customization but for recurring events
*
* Uses two PHP anonymous functions so only compatible with PHP 5.3+
*/
add_filter( 'tribe_events_get_current_month_day', function( $days_events ) {
if ( ! function_exists( 'tribe_event_is_all_day' ) || $days_events['events']->custom_all_day_reordering_done || empty( $days_events['events']->posts ) )
return $days_events;
usort( $days_events['events']->posts, function( $event_a, $event_b ) {
$a_all_days = tribe_event_is_all_day( $event_a->ID );
$b_all_days = tribe_event_is_all_day( $event_b->ID );
if ( $a_all_days && ! $b_all_days ) return 1;
if ( ! $a_all_days && $b_all_days ) return -1;
return 0;
} );
$days_events['events']->rewind_posts();
$days_events['events']->custom_all_day_reordering_done = true;
return $days_events;
} );
@mvaneijgen
Copy link

Hey, any idea how to make this work for the list view of The Events Calendar?

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