Skip Navigation

[Gelöst] Display Current and Upcoming Events

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user is having issues with their date filter on views.

Solution:

Normally the issue here is that its quite possible that you have the date field to compare as a String. However since date fields created in types are stored as timestamps then you need to let the comparison be made as Number in the filter.

Example
Start date is a "Number" that is "Lower than or equal" to "Today"

This support ticket is created vor 4 Jahre, 6 Monate. 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.

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 5 Antworten, has 2 Stimmen.

Last updated by seanN-5 vor 4 Jahre, 6 Monate.

Assisted by: Shane.

Author
Artikel
#1337823

I am using Toolset to create custom post types for Exhibitions, Performances and Events. Exhibitions tend to run over a 30-60 day period. Performances and Events are one-day items.

To display current and upcoming events I need to show events that are currently in progress plus events that have not happened yet.

For each of the custom post types I have a "start date" and an "end date"'.

My current filter is:
Start date is a "String" that is "Lower than or equal" to "Today"

And

End Date is a "String" that is "Lower than or equal" to "Today"
----
That of course shows current events but does not show upcoming events because the "start date" is not lower than today.

If I choose "Or", then past events show because their start date is prior to today.
----
If I could use And and Or in a query I could solve my problem

Start date is a "String" that is "Lower than or equal" to "Today"

And

End Date is a "String" that is "Lower than or equal" to "Today"

Or

Start Date is a "string" that is greater than "today"
--
Is there a way to accomplish the query I have described?

**Not sure this helps but url is hidden link

#1337881

Shane
Supporter

Languages: Englisch (English )

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

Hi Sean,

Thank you for getting in touch.

Could you try the setting the filters like this.

Start date is a "Number" that is "Lower than or equal" to "Today"

And

End Date is a "Number" that is "Lower than or equal" to "Today"

The reason why you need to set it as number is because the date fields made with our Types plugin stores their values as a timestamp.

Please try this and let me know if this helps.
Thanks,
Shane

#1337957

Thanks for the fast response Shane. Just tried it. That combination pulls all past events/exhibitions/performances.

That makes sense though because an event that happened in January of 2015 would have a:

Start Date that is lower or equal to today: and
End Date that is lower or equal to today

For this I'm looking to pull items that are current: for example a Start Date September 1 2019 and End Date of October 31, 2019

and in the future: Start Date October 1 2019

#1337959

Here is the query from toolset:

Select items with field:
Start Date is a number lower than or equal TODAY()
AND
End Date is a number lower than TODAY()

#1337981

Shane
Supporter

Languages: Englisch (English )

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

Hi Sean,

Your current query will only pull past events.

For future events it needs to be

Start Date is a number lower than or equal TODAY()
AND
End Date is a number greater than TODAY()

This will ensure that it will return the events that are current.

Currently you can only apply 1 filter to each date field.

So for events with future start date you will need to create a new view and set the filter to Start Date is a number greater than or equal TODAY()

Thanks,
Shane

#1339785

Thanks Shane. Since I could not do what I wanted I separated events occurring today and events occurring in the future.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.