Skip Navigation

[Resolved] Greater than or equal to comparison doesn’t work

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user was trying to implement a view filter that will compare values as numbers(>= <=, etc.) for a checkboxes field. Solution:
It won't be possible to search using a comparison on a Checkboxes field. Because the field's values are stored as serialized arrays, and search within them is always performed using a "LIKE" operator. Check the possible operator for custom field search here https://developer.wordpress.org/reference/classes/wp_meta_query/

If you need to use "greater than" operator you will need to use a different field type.

I'll suggest using a select field instead of a checkboxes field. You may also use a number field or a single-line field.

This support ticket is created 3 years, 6 months 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
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Marcel 3 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2070915

I want a filter to show all results that are greater than or equal to the selected value. I set that in the filter, but it doesn't seem to work. Please check this screen recording: hidden link.

#2071707

Hello and thank you for contacting Toolset support.

It won't be possible to search using a comparison on a Checkboxes field. Because the field's values are stored as serialized arrays, and search within them is always performed using a "LIKE" operator. Check the possible operator for custom field search here https://developer.wordpress.org/reference/classes/wp_meta_query/

If you need to use "greater than" operator you will need to use a different field type.

Are expecting a post to have multiple values for this field? If not, I'll suggest using a select field instead of a checkboxes field.
You may also use a number field, or a single line field.

Let me know more details about this field? Especially if you expect it to have multiple values. And I may better advise you.

#2071717

Hi Jamal,

Thanks for your answer. I know enough, I'll have to use a number field or a select field in this case. No problem 🙂