Skip Navigation

[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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Shane 1 year, 10 months ago.

Assisted by: Shane.

Author
Posts
#2407833

Tell us what you are trying to do?

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.

What is the link to your site?

hidden link

#2408059

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dimitri,

If I understand the query correctly, you want to sort your view by the Start and End date or is it you want to sort it by the End date?

Can you please clarify for me.

Thanks,
Shane

#2408361

Hi Shane,
Not really. Let me try to clarify.

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.

Cheers

#2408605

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Dimitri,

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.