Change Order of Past Events in The Events Calendar Plugin

Share Your Thoughts

The Events Calendar is a great calendar plugin for WordPress. It comes in both free and Pro versions and is very flexible. However, by default the events are displayed in chronological order and this might not suit your site.

If you want to reverse the order of your events in The Events Calendar, you can add this function to your functions.php file.

// 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);

As an example, here’s where I used this: STEPS Centre Events page.

WordPress , ,


What do you think?

It's good to talk!

Your email address will not be published. Required fields are marked *

Please answer before submitting form * Time limit is exhausted. Please reload CAPTCHA.