Skip to content

Instantly share code, notes, and snippets.

@theeventscalendar
Forked from elimn/functions.php
Created August 10, 2015 22:55
Show Gist options
  • Select an option

  • Save theeventscalendar/27b25dc4e5e4ea7e3f31 to your computer and use it in GitHub Desktop.

Select an option

Save theeventscalendar/27b25dc4e5e4ea7e3f31 to your computer and use it in GitHub Desktop.
Change past event views to reverse chronological order
<?php
// Changes past event views to reverse chronological order
function tribe_past_reverse_chronological ($post_object) {
$past_ajax = (defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['tribe_event_display'] === 'past') ? true : false;
if(tribe_is_past() || $past_ajax) {
$post_object = array_reverse($post_object);
}
return $post_object;
}
add_filter('the_posts', 'tribe_past_reverse_chronological', 100);
@rathert
Copy link

rathert commented Mar 13, 2017

The code works, unless you go to the list of past events following the "past events” link from the list of future events:

  • if you click on "past events", all past events are still sorted with the first on top.
  • only after manually reloading the page, the events appear in the correct order.

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