Created
March 15, 2018 16:02
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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