events list ascending by default

Home Forums Calendar Products Events Calendar PRO events list ascending by default

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1069267
    Sally Newcomb
    Participant

    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?

    #1069577
    Geoff
    Member

    Hi 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!
    Geoff

    #1069584
    Sally Newcomb
    Participant

    Ah 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?

    #1070249
    Geoff
    Member

    Oh 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,
    Geoff

    #1070601
    Sally Newcomb
    Participant

    Thank 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 🙂

    #1070864
    Geoff
    Member

    Sure 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘events list ascending by default’ is closed to new replies.