sort events by ending date (closest to furthest)

Home Forums Calendar Products Events Calendar PRO sort events by ending date (closest to furthest)

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1199646
    Colin Purchase
    Participant

    Hi there i want to sort the events by descending order of event start date thanks for example: 30 Nov 2016 then next post should be 29 Nov 2016

    #1200120
    Hunter
    Moderator

    Hey Colin,

    I did a little research but was unable to find any examples of what you seek being done, though there might be some out there. Unfortunately, these types of requests are outside what we’re able to cover on the support forums. I recommend reviewing our Using tribe_get_events KB article as it should help get you started.

    Sorry we can’t do more and best of luck. Cheers!

    #1200149
    Colin Purchase
    Participant

    Hi i just need to display events descending order according to there dates

    #1200584
    Hunter
    Moderator

    Hey Colin,

    I’m looping in Nico here to help further assist. He should be able to take a look tomorrow, so if you don’t hear back from him, feel free to respond to this thread as a reminder for us. Thanks for your patience and take care!

    #1201425
    Colin Purchase
    Participant

    its a reminder for you guys still didn’t able to get any solution from you guys

    #1202925
    Nico
    Member

    Hey Colin,

    Thanks for the patience while I worked on this and sorry for the delay!

    To reverse the order of events paste the snippet below in your theme’s (or child theme’s) functions.php file:

    /* Tribe, reverse events order */
    function tribe_modify_events_order( $query ) {

    if ( tribe_is_list_view() && !tribe_is_past() ) {

    $query->set('order', 'DESC');
    }

    remove_action( 'pre_get_posts', 'tribe_modify_events_order' , 100 );
    }

    add_action( 'pre_get_posts', 'tribe_modify_events_order' , 100 );

    Note: it will only work on list view, as it makes no sense to revert the order or month or week view. Let me know if I should add more views for this (like photo or map view).

    Please let me know if this works for you,
    Best,
    Nico

    #1202992
    Colin Purchase
    Participant

    Sorry to tell you that code you provided does not work let me explain you once more i want to sort the events by there ending date which are closest to the current date for example if current date is 8 December i want to show the event first which ending date is 8 December then the next one would be 9 December (event ending date)
    kindly please look at the picture i have attached in this the event which ending date is 28 December i want to show it first then with further on with there ending date

    #1204176
    Nico
    Member

    Thanks for clarifying! My bad, giving the thread a new look what you were asking was pretty clear sorry for that.

    Please try this updated snippet:
    /* Tribe, reverse events order */
    function tribe_modify_events_order( $query ) {

    if ( ( tribe_is_photo() || tribe_is_list_view() ) && !tribe_is_past() ) {

    $query->set( 'orderby', 'meta_value' );
    $query->set( 'meta_key', '_EventEndDate' );
    }

    remove_action( 'pre_get_posts', 'tribe_modify_events_order' , 100 );
    }

    add_action( 'pre_get_posts', 'tribe_modify_events_order' , 100 );

    Let me know if it works for you as expected,
    Have a great weekend,
    Nico

    #1206272
    Colin Purchase
    Participant

    Hi i am sorry to tell you again that didnt work for me

    #1206340
    Colin Purchase
    Participant

    Let me clarify once again for sake today is 15-december-2016 and i want to sort the events by their ending date which are close to current date (Current-date:15-december-2016) event ending date like (16-December-2016,17-December-2016,1-January-2017,….)

    #1207798
    Nico
    Member

    Thanks for following up Colin!

    I’m mostly sure that’s the way it’s working on my end (ordering by upcoming event end date, dic 15 – 16 – 17, etc). Also Hunter (who was originally helping you here) gave the script a try and it seems to be working on his end.

    Can you try switching to a default theme + disable all plugin (not ours of course) and add the script to the default theme’s functions.php file?

    If you have a staging site were you can set this up I’d be glad to take a look also.

    Please let me know about it,
    Best,
    Nico

    #1215860
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘sort events by ending date (closest to furthest)’ is closed to new replies.