Skip to content

Instantly share code, notes, and snippets.

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 barryhughes/ec630ab11861be053386de5fa5dc9f2d to your computer and use it in GitHub Desktop.
Save barryhughes/ec630ab11861be053386de5fa5dc9f2d to your computer and use it in GitHub Desktop.
Reverses the order of posts on each individual photo view page (but does not reverse the sequence as a whole ... for TEC/ECP 4.5/4.6). In other words, this doesn't necessarily mean we'll see the furthest-in-the-future event first, rather it means each page on photo view will contain the same range of events but in the reverse order.
<?php
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