Skip Navigation

[Resolved] Checkbox search is searching AND instead of OR

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

Problem:

What I need is if I choose two checkboxes from the same filter (see screenshot) I need that to be an OR search. Right now it's AND so it doesn't show results when I choose more than one at a time.

Solution:

Edit the view, in section "Query Filter". edit the filter from:
Course Type is a string equal to URL_PARAM(wpv-wpcf-course-type)

To:
Course Type is a string in URL_PARAM(wpv-wpcf-course-type)

Relevant Documentation:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
IN
A list of values
Checks if the custom field value is within the list of compare values

This support ticket is created 6 years, 10 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by chrisS-18 6 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#619843

Has something changed with the Custom Search functionality? I've done tons of these with no trouble but this simple Search is giving me fits.

hidden link

The search needs to be an AND search within each checkbox group. I actually got an error message about this that forced me to "correct the search" to an AND search. I need an OR search on multiple checkboxes for one variable. I've done this on other sites in the past and OR was the default.

What has changed?

#619866
filter.JPG

Hi,

That is a built-in settings of Views, you can change it by this:
Edit the view "Products With Search 3":
hidden link

click "Screen Options", option "Full custom display mode", then you will be able to see the section "Query Filter", find "Custom field filter", and click button "Edit", there is an option "Relationship to use when querying with multiple fields:", you can change it from "AND" to "OR", see screenshot filter.jpg

#620056
Screen Shot 2018-02-27 at 7.45.57 AM.png

Thank you but that doesn't solve the problem.

What I need is if I choose two checkboxes from the same filter (see screenshot) I need that to be an OR search. Right now it's AND so it doesn't show results when I choose more than one at a time.

#620319

Thanks for the details, I have done below modification in your website:
Edit the view "Products With Search 3", in section "Query Filter". edit the filter from:
Course Type is a string equal to URL_PARAM(wpv-wpcf-course-type)

To:
Course Type is a string in URL_PARAM(wpv-wpcf-course-type)

Please test again, check if it is fixed or not.

More help:
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
IN
A list of values
Checks if the custom field value is within the list of compare values

#620550

Perfect! Problem solved.

thank you very much!