Ordering Past events in descending order

Home Forums Calendar Products Events Calendar PRO Ordering Past events in descending order

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #873703
    btellock
    Participant

    Hello,
    Looking for a way to order the past events in descending order (most recently expired event first). Any help is much appreciated. Thanks!

    #873990
    Geoff
    Member

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

    Good question. You could create a page template that outputs past events in descending page. Here is a handy tutorial on how to use the tribe_get_posts() function. It’s a lot like the default WordPress get_posts() function.

    That means you are able to set the “eventDisplay” to “past” and “order” to “DESC”. You may need to fiddle with it a little bit to meet your specific needs, but this should get you started in the right direction.

    Does this help answer your question? Please let me know. 🙂

    Cheers!
    Geoff

    #874044
    btellock
    Participant

    Thanks, Geoff. I do have different event categories that I would need to display on their own “page”. i.e. past Classes, Past Exhibitions, etc. Would the suggested approach still be the best option. Can I ask why the past archives display in ASC order by default? That seems a little backwards. For example I have TEC on this site (http://www.laco.org/attend/category/orchestral-series/past/?action=tribe_list&tribe_paged=1) and the past events display in DESC by default. Did something change with 3.8?

    #874794
    Geoff
    Member

    My pleasure, Brian! I’m glad that helps. 🙂

    Yes, I would recommend the same approach on a category basis as well.

    Can I ask why the past archives display in ASC order by default?

    Events are displayed in the order in which they occur (typically a Start Date). For example, in List View, the events at the top of list are the ones closest to the current date and move more toward the future as you browse down. Similarly, paging back to past events is like flipping backwards in time and events are ordered further the current date in the other direction. In other words, everything is in relation to the current date.

    the past events display in DESC by default. Did something change with 3.8?

    The Past Events view should be ascending by default. Are you using the “Default Event Template” under Events > Settings > Display? If not, can you change it and see if that makes a difference? If you already have it selected, will you please update to the latest version (3.8.1) and see if that helps? I see you’re noted that you’re currently using version 3.8 and I wonder if updating will resolve the issue.

    Please give that a shot and let me know what you find.

    Cheers!
    Geoff

    #876790
    btellock
    Participant

    Thanks, Geoff. I do indeed need the past events to display in DESC order. Do you have a link you can share to get me rolling with creating this custom page template? And can I copy an existing page template as a starting point? Any additional hints to help get me on the right track is much appreciated. Thanks!

    #876870
    Geoff
    Member

    Hi Brian, thanks for following up!

    I’m a little limited in how much custom support I can provide here in the forums, but I’d be happy to point you to some resources to get your rolling. 🙂

    Creating a page template for the calendar will be exactly like setting up any other page template in WordPress. Here’s the WordPress Codex article that covers that process in great detail.

    Once you have the basic structure of your template set up, you can add the query for your events. The examples in this tutorial will definitely help get you started on using the tribe_get_events() function to output the events you want to display. Your usage will vary, but your query might look something like this:

    // Grab the last 5 next past events in descending order
    $events = tribe_get_events( array(
    'eventDisplay' => 'past',
    'posts_per_page' => 5,
    'order' => 'DESC',
    ) );

    With your query set up, you can print the content for each event inside the loop. For example:

    // display the title and content
    foreach ( $events as $post ) {
    setup_postdata( $post );
    
    the_title();
    echo tribe_get_start_date();
    the_content();
    }

    A full list of classes and functions is available in our documentation. Definitely worth checking out. 🙂

    I hope this helps!

    Geoff

    #897191
    Geoff
    Member

    Hey there, Brian! Just checking in to see if there’s been any further update or if you still need assistance on this one.

    We’ve been working on a snippet that might help reverse the chronological order of past events. Give it a shot and let me know if it does the trick.

    Hope this helps. 🙂

    Cheers!
    Geoff

    #904193
    btellock
    Participant

    This works perfectly! Thank you very much!

    #904251
    Geoff
    Member

    Awesome! So glad that does the trick.

    I’ll 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. 🙂

    Also, we’d love it if you have a few moments to share your thoughts about the plugin on our review page. It’d be awesome to hear what you think.

    Cheers!
    Geoff

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Ordering Past events in descending order’ is closed to new replies.