Skip Navigation

[Resuelto] Filtering by custom field date range

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 2 años, 3 meses. 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.

This topic contains 3 respuestas, has 2 mensajes.

Last updated by Craig hace 2 años, 3 meses.

Assigned support staff: Christian Cox.

Autor
Mensajes
#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!