Skip Navigation

[Resolved] Group post types by if they are upcoming events of past events.

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 7 years ago.

Assisted by: Nigel.

Author
Posts
#594844

I'd like group my custom post type by if they are an upcoming event or past. I'd imagine this would be done using some sort of shortcode. But I haven't really seen any examples of how that would work.

Here is an example.

Upcoming Events ---
[Anual group dinner: Dec 21, 2017]

Past Events --
[Group Meetup: Nov 5, 2017]

#594990

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

You can't do this with a single View. You could order them in reverse-date order but you wouldn't be able to add a title to mark the transition from future to past events.

So the solution is one View showing upcoming events in your preferred order, and a separate View showing past events in your preferred order.

You will need a Query Filter that compares your date field as a number to TODAY().

See: https://toolset.com/documentation/user-guides/filtering-views-query-by-date/

#595169

So right now I'm doing a view with a custom search. Can I do 2 views and still have one search filter the results?

#595502

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, if you create two Views that both use the same filters (e.g. using the same custom fields), and insert one full View (search form and results) and just the results for the second View. (You'll see this option when using the Fields and Views button to insert the wpv-view shortcode.)

Note that the only limitation is that the results need to update via a page reload. If you choose ajax it will only update one of the Views.