Skip Navigation

[Resolved] Checkbox Filter forcing AND condition on results – can it be changed to OR?

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

Problem:
How can I force a Taxonomy Custom Filter select field in Views to return ALL terms in the search, until the user makes a more specific choice anc submits a search with one Term selected?

Solution:
You can just add a default value, when in the option "Use existing custom field values" (when editing the Filter)

You will see that several options become available once you start to type in the "Default value:" field.

Choose one of them (all, as example) and that will be the new default value when not submitting any more particular choice in the Filter.

More details here:
https://toolset.com/forums/topic/checkbox-filter-forcing-and-condition-on-results-can-it-be-changed-to-or/#post-481829

This support ticket is created 7 years, 4 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by neilM-9 7 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#481766

I've set up a custom search on a View for a Toolset-controlled custom post type. The search has two parameters:

1) Keyword search box
2) Category filter 'Supplier Type' - based on a multi-check box Post Field assigned to the custom post type - displaying as a drop-down

At the moment, if a user searches for a known database entry using relevant keywords, the search doesn't return any valid results, *unless* the Supplier Type drop-down is also set to one of the relevant Supplier Type options. At which point, re-running the search returns valid results.

In other words, there seems to be an AND relationship between the two search parameters. I need to change this to an OR relationship, so the user can *either* search by keyword, or use the Supplier Type drop-down to filter the entire list of Suppliers.

I used the 'New Filter' wizard within Edit View to set up the custom search and it generated the following code:

[wpv-filter-start hide="false"]
[wpv-filter-controls]

[wpv-filter-search-box]

[wpml-string context="wpv-views"]Supplier Type:[/wpml-string] [wpv-control field="supplier-type" url_param="supplier-type" type="select" auto_fill="wpcf-supplier-type" auto_fill_sort="asc"]

[wpv-filter-submit name="Search Suppliers" type="button"][wpv-filter-reset reset_label="Reset List" type="button"]

[/wpv-filter-controls]
[wpv-filter-end]

Please could you refer replies to darren@darrenturpin.co.uk? I'm Neil's website manager.

Thank you.

#481829

This is by design.

The issue here is that you probably use the option "Use existing custom field values" when you insert the Checkboxes Field as a Select Search Field.

This makes the query always grab an existing value, and passes it to the URL param automatically.

To solve this please edit the Checkboxes (Select) Field filter an use "Use manually entered values".
Make sure to leave a "blank value", this means that value will return "all results".

This will then always grab "All values" and return valid results.

OR, you can just add a default value, when in the option "Use existing custom field values"
You will see that several options become available once you start to type in the "Default value:" field.

Both will solve the problem

#482196

Thank you Breda, the second solution worked exactly as needed.

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