[Resolved] Sort list of events (custom types) by date – Move past events to back of list
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
We have set up a list of events ursing custom types, ordered by 'start date' ('start date' is a custom field).
Everything is working as it is supposed to, but I would like to change the order so past events go to the back of the list.
To clarify:
Order as is:
1st of may 2022 - 1st of july 2022 - 1 of october 2022
Order I would like to achieve:
1st of july 2022 - 1 of october 2022 - 1st of may 2022 (so, May 1st is shown at back since it has passed)
Is there any documentation that you are following?
No. Could you point me to the relevant documentation?
We are using legacy views.
We set up a custom type called 'event'. It has several custom fields, but the one relevant to what we are trying to achieve is the start date. We didn't set an end date...
For the moment, all events are ordered by start date (ASC).
Since we are in june right now, and the logical order starts with januari, we were wondering whether it would be possible to move the past events to the back of the list.
So, we want to sort all future events by start date and have the past events move to the back of the list, so we can add some sort of message like 'see you next year'.
I feel it should be possible. I'm thinking nested views, but I'm not really sure how to set it up.
Based on what I see here it is evidence of sorting by multiple custom fields because you will want the start dates to be in ASC order however the ones with an end date that has already gone you want it to be in DESC order.
This is quite complex and can only be achieved with using a custom hook. I dont believe a nested view will solve this one.
There might also be a way to do it with just 2 views as well. Where you can only show the posts where the end date is greater than today and then in another view below this one u show the posts where the end date is less than today.
Please let me know what you think of this.
Thanks,
Shane
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.