Home › Forums › Calendar Products › Events Calendar PRO › events list ascending by default
- This topic has 5 replies, 2 voices, and was last updated 8 years, 2 months ago by Geoff.
-
AuthorPosts
-
February 8, 2016 at 5:22 am #1069267Sally NewcombParticipant
Is there a way to show the events list ascending by default? I need to reverse the ‘Start Date’ filter to order them in an ascending order so the next event to happen is at the top of the list. Presumably there is a way of altering the pre_get_posts in my custom functions.php?
February 8, 2016 at 8:44 am #1069577GeoffMemberHi Sally and welcome to the forums!
Good question. You should be able to reverse the list of events with something like this:
// Changes event views to reverse chronological order function tribe_reverse_chronological ($post_object) { $past_ajax = (defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['tribe_event_display'] === 'past') ? true : false; if(tribe_is_upcoming() ) { $post_object = array_reverse($post_object); } return $post_object; } add_filter('the_posts', 'tribe_reverse_chronological', 100);
I haven’t tested that myself but hopefully it provides the blueprint for reversing the order of events.
Cheers!
GeoffFebruary 8, 2016 at 8:59 am #1069584Sally NewcombParticipantAh no, that changed the website frontend, I want to reverse the listings in the admin area so that the next event to take place is at the top of the list so it’s easier for the admin. How do I do that?
February 9, 2016 at 6:50 am #1070249GeoffMemberOh sorry, I took your question as wanting to affect the front end of the site–my apologies!
I’m afraid there is no way to do that right out of the box without some custom development. You could actually still use the snippet I gave you as a starting point, however, changing it so that it is looking at the admin rather than the front end:
function tribe_reverse_chronological ($post_object) { $past_ajax = (defined( 'DOING_AJAX' ) && DOING_AJAX && $_REQUEST['tribe_event_display'] === 'past') ? true : false; if(is_admin() ) { $post_object = array_reverse($post_object); } return $post_object; } add_filter('the_posts', 'tribe_reverse_chronological', 100);
That will order events by start date from first to last (ascending order) but will need to be updated so that it starts at the current date rather than the beginning of time.
Sorry I don’t have a more concrete solution for you here, but I do hope this at least helps get you started! And, of course, if you have any specific questions along the way, I’d be happy to keep this thread open and help as best I can.
Thanks,
GeoffFebruary 10, 2016 at 1:56 am #1070601Sally NewcombParticipantThank you but I think I might have to give up on this. It’s a shame. In the past I’ve used EME as an events plugin and it does list events in the ascending order I want at the backend of the website. Could you add this to your list of future enhancements? I see others have asked for the same. Please 🙂
February 10, 2016 at 7:20 am #1070864GeoffMemberSure thing, Sally! In the meantime, it would be awesome if you could add your vote for the feature request — it looks like a great idea but definitely does need some extra votes in there.
I’ll go ahead and close this thread but please do feel free to open another one if any other questions pop up and we’d be happy to help.
Cheers.
Geoff -
AuthorPosts
- The topic ‘events list ascending by default’ is closed to new replies.