Display Past Events in Reverse Order

Home Forums Calendar Products Events Calendar PRO Display Past Events in Reverse Order

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #885103
    James Lavine
    Participant

    I’m displaying a list of past events here, but I’d like it to display the most recent first. Is there a simple way to do this?

    Thanks!
    James

    #885215
    Geoff
    Member

    Hi there, James! Thanks for getting in touch and welcome back to the forums. 🙂

    Great question. I do want to note first of all, though, that we are fairly limited in terms of helping out with custom development questions like this one. That said, we’d love to point you in the right direction if we can.

    One idea would be to use use a theme override (see more on this in our Themer’s Guide) of the list.php template and use a conditional statement like this to create a new events query for past events:

    if tribe_is_past() {
    // Run your query
    }

    You can use tribe_get_events() to run your query and set the parameters to display past events in descending order. That might look something like this:

    $events = tribe_get_events( array(
    'eventDisplay' => 'past',
    'order' => 'DESC',
    ) );

    There’s a lot more detail on using tribe_get_events() here, including some handy examples. 🙂

    Does that make sense? Will that work for you? Please let me know.

    Cheers!
    Geoff

    #894394
    Todd
    Participant

    Does that mean there’s no filter-hook to simply change the ‘order’ parameter in the DEFAULT query? Like …

    add_filter(‘tec_default_query_filter’,’fix_past_list_order’);
    function fix_past_list_order(){
    if tribe_is_past() {
    $the_default_query[‘order’] = ‘DESC’;
    }
    }

    Does a hook like “tec_default_query_filter” exist? Or do we really need to use tribe_get_events() to build a custom version of the Past-List functionality — just to change the order?

    #897018
    Geoff
    Member

    Hey there, Todd! Thanks for chiming in. 🙂

    That’s certainly a good assumption and would seem likely–however, given the complexity of the many possible views and the queries supporting them, it’s not quite that easy.

    We’ve been working on and trying out a new snippet that can handle this. Give it a try and see if it helps.

    Cheers!
    Geoff

    #897025
    James Lavine
    Participant

    That works perfectly! Thanks so much Geoff 🙂

    #897056
    Geoff
    Member

    My pleasure, James! I’m so glad that helps.

    I’m going to go ahead and close this thread, but please feel free to hit us up with a new thread if any other questions pop up. We’d be happy to help. 🙂

    Cheers!
    Geoff

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Display Past Events in Reverse Order’ is closed to new replies.