Skip Navigation

[Résolu] Filtering by custom field date range

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I have tried to add a custom field date filter but it doesn't seem to work correctly. No results are found in the View, but there are posts that have matching custom field date values. The filter is configured as "The field Online Event Date is a DATE that is greater than or equal the following: TODAY"

Solution: The "DATE" data format doesn't work well with Types date fields, counter-intuitively. It's best to choose the number or unsigned data type when filtering by a custom date field created in Types.

This support ticket is created Il y a 3 années et 9 mois. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 réponses, has 2 voix.

Last updated by Craig Il y a 3 années et 9 mois.

Assisted by: Christian Cox.

Auteur
Publications
#1665771

I am trying to display a view based on date. I have my CPT (Online Events) with entries which have dates set before and after today. These all display fine when "The field Online Event Date is a DATE that is greater than or equal the following: TODAY" is removed. But as soon as I add it in, I get the message that no online events can be found.

Any ideas as to why the view won’t work when this filter is enabled?

Kind regards,
Craig

#1667169

Hi, is the "Online Event Date" field a custom date field created in Types? If so, then it's best to change the comparison from a DATE datatype to a number datatype:
The field Online Event date is a NUMBER that is greater than or equal the following: TODAY

Types date fields store dates in the database using a Unix timestamp format, which is basically an integer. If you're making comparisons against it you should choose "number" as the datatype. Let me know if this filter still doesn't behave as you'd expect and we can take a closer look.

#1667311

Hi Christian.

That has solved the issue. I never thought to try NUMBER. Duly noted.

Thank you very much for your help.

Kind regards,
Craig

#1667313

My issue is resolved now. Thank you!

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