Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Created March 15, 2018 16:02
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 cliffordp/c180a419c53b0243ac4811f7a6e0f02c to your computer and use it in GitHub Desktop.
Save cliffordp/c180a419c53b0243ac4811f7a6e0f02c to your computer and use it in GitHub Desktop.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment