Home › Forums › Calendar Products › Events Calendar PRO › sort events by ending date (closest to furthest)
- This topic has 12 replies, 5 voices, and was last updated 9 years, 3 months ago by
Colin Purchase.
-
AuthorPosts
-
November 30, 2016 at 2:08 am #1199646
Colin Purchase
ParticipantHi 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
November 30, 2016 at 7:51 pm #1200120Hunter
ModeratorHey 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!
November 30, 2016 at 10:56 pm #1200149Colin Purchase
ParticipantHi i just need to display events descending order according to there dates
December 1, 2016 at 4:11 pm #1200584Hunter
ModeratorHey 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!
December 5, 2016 at 12:10 am #1201425Colin Purchase
Participantits a reminder for you guys still didn’t able to get any solution from you guys
December 7, 2016 at 3:35 pm #1202925Nico
MemberHey 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,
NicoDecember 7, 2016 at 10:14 pm #1202992Colin Purchase
ParticipantSorry 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 dateDecember 9, 2016 at 2:01 pm #1204176Nico
MemberThanks 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,
NicoDecember 14, 2016 at 9:36 pm #1206272Colin Purchase
ParticipantHi i am sorry to tell you again that didnt work for me
December 15, 2016 at 3:37 am #1206340Colin Purchase
ParticipantLet 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,….)
December 19, 2016 at 10:46 am #1207798Nico
MemberThanks 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,
NicoJanuary 10, 2017 at 8:35 am #1215860Support Droid
KeymasterHey 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 -
AuthorPosts
- The topic ‘sort events by ending date (closest to furthest)’ is closed to new replies.
