Events Calendar PRO: Photo View: Reverse the display order of events per page (i.e. the same events are displayed, just with the nearest-upcoming on the bottom instead of on the top).
<?php
/**
* Events Calendar PRO: Photo View: Reverse the display order of events per
* page (i.e. the same events are displayed, just with the nearest-upcoming
* on the bottom instead of on the top).
*
* @link https://gist.github.com/cliffordp/c180a419c53b0243ac4811f7a6e0f02c
* @link https://theeventscalendar.com/support/forums/topic/post-page-order/
*/
function photo_view_reorder_posts( $posts ) {
remove_filter( 'the_posts', 'photo_view_reorder_posts' );
return array_reverse( $posts );
}
function photo_view_reorder_listen( $query ) {
if (
'photo' === $query->get( 'eventDisplay' )
|| tribe_is_ajax_view_request( 'photo' )
) {
add_filter( 'the_posts', 'photo_view_reorder_posts' );
}
}
add_action( 'tribe_events_pre_get_posts', 'photo_view_reorder_listen' );