CS forms: Filter and Faceted (OR instead of AND)

Hi,

I have archive layout page, fetching portfolio items. (ref themeco YT video)
Im using CS forms to filter (4 checkbox lists) the results (portfolio categories).
Each checkbox list has a looper provider (All terms: Parent term) and a Looper consumer (all)
It works well, but the issue I have is when i select filter from different checkbox lists, then results come as OR instead of AND.
Results are messy.

I do I change it to AND?

Thank you

Hey @CulturalInfusion,

Depending on how your main portfolio Looper Provider is configured to read the form data, there are a few simple ways to change the filtering relationship from OR to AND.

Here are the solutions for each common setup:


Method 1: If using a single name for all lists (or a multi-select parameter)

If all 4 checkbox lists share the same input name (e.g., portfolio-category[] or category[]), or if a list submits multiple values, they are queried as an array within a single taxonomy parameter. By default, WordPress combines these terms using the IN operator (which acts as OR).

A. If your Looper Provider is set to Query Builder:

  1. Select the Element containing your main portfolio items Looper Provider.
  2. Under the Taxonomy settings section, locate your category filter.
  3. Look for the Operator dropdown (or “Must have all selected items” / “All” toggle depending on your Cornerstone version).
  4. Change the operator from IN / Any to AND / Must have all selected items.

B. If your Looper Provider is set to Query String:

If you are using the tax_query array structure in your query string, add &tax_query[0][operator]=AND to your query.

  • Example AND Query String:
    post_type=x-portfolio&tax_query[0][taxonomy]=portfolio-category&tax_query[0][field]=slug&tax_query[0][operator]=AND&tax_query[0][terms]={{dc:url:param key="portfolio-category"}}
    

Method 2: If using different names for each of the 4 Checkbox Lists

If your checkbox lists have different names (e.g., cat_group_1, cat_group_2, etc.) and submit separate parameters, you need to configure your Looper’s taxonomy query relation to be AND.

A. If your Looper Provider is set to Query String (Using tax_query arrays):

In WordPress, multiple taxonomy queries are combined using a relation parameter. If you have defined multiple tax_query blocks joined by OR, change the relation key to AND.

  • Change this (OR):
    post_type=x-portfolio&tax_query[relation]=OR&tax_query[0][taxonomy]=portfolio-category&tax_query[0][terms]={{dc:url:param key="cat_group_1"}}&tax_query[1][taxonomy]=portfolio-category&tax_query[1][terms]={{dc:url:param key="cat_group_2"}}...
    
  • To this (AND):
    post_type=x-portfolio&tax_query[relation]=AND&tax_query[0][taxonomy]=portfolio-category&tax_query[0][terms]={{dc:url:param key="cat_group_1"}}&tax_query[1][taxonomy]=portfolio-category&tax_query[1][terms]={{dc:url:param key="cat_group_2"}}...
    

B. If your Looper Provider is set to Query String (Using URL parameters directly):

If you are concatenating values into a single query string parameter, WordPress treats commas (,) as OR logic, and plus signs (+) as AND logic.

  • Change this (OR):
    post_type=x-portfolio&portfolio-category={{dc:url:param key="cat1"}},{{dc:url:param key="cat2"}},{{dc:url:param key="cat3"}},{{dc:url:param key="cat4"}}
    
  • To this (AND):
    post_type=x-portfolio&portfolio-category={{dc:url:param key="cat1"}}+{{dc:url:param key="cat2"}}+{{dc:url:param key="cat3"}}+{{dc:url:param key="cat4"}}
    

Method 3: Change the Delimiter in CS Forms Checkbox List Settings

If you have set the Return Type of your Checkbox Lists in Cornerstone Forms to Delimiter:

  1. Click on each of your Checkbox List elements in the builder.
  2. In the inspector panel, locate the Delimiter input field under the settings (which defaults to a comma ,).
  3. Change the delimiter from , to +.
  4. Because WordPress natively parses + as an AND operator for taxonomy parameters in query URLs, this change will instantly switch your query behavior to match all selected categories!

If none of that helps, provide the following details in a Secure Note

  • WordPress Login URL
  • Admin username and password
  • URL of the page where you placed the faceted search.

You can find the Secure Note button at the bottom of your posts.