Category and Taxponomy term filters

Frontend Search Settings -> Categories & Taxonomy Terms

On this option panel, you can choose taxonomy term filters to be displayed on the front-end.

Choosing terms

First, use the Select the taxonomy option to select which taxonomy terms you want to use. For example, if you want post categories, choose the post - Categories option.

You can select individual items, or the "Use all from ..." option, in which case you can define exclusions for that taxonomy - in case you want to display everything, except some items.

For example, I want to display every category except the Uncategorized:

Display mode

Clicking the Change display mode button opens a pop-up window, where you can configure the filters layout.

Posts (or any CPT) with missing terms and the filter

By default, the taxonomy term filter includes items, that does not have any relation to the taxonomy terms visible in the filter.

If you prefer not showing these items instead, then you can do that by turning off the Show posts/CPM with empty (missing) taxonomy terms? option under the Frontend Search Settings -> Advanced panel.

To better understand the difference, please check the images below.

Term logic (for checkboxes)

The term logic option determines how each checkbox is validated agains the results per each taxonomy. By default, all selected terms must match in order for the result to display.

To understand how each possible logics respond, let's consider an example.

We have 3 categories: Actors, Female and Male, and Posts that are associated with each category accordingly. The screenshot below shows the default state, and all of the possible results.

All of the selected terms should match logic (default)

Any of the unchecked checkboxes is treated as an exclusion. Thus unchecking 'Female' will exclude anything categorized as 'Female', and the checked ones must still apply.

At least one of the terms should match logic

This is one of the simplest logic - thus if any of the checked checkboxes match the post, it is considered as a possible result. Unchecked checkboxes are ignored.

Because with this logic the unchecked checkboxes are ignored, using term based inclusions on the Advanced Options -> Exclude/Include results panel is not recommended.

For example: If category Actors is choosen in both options (used in filter as well as on the advanced options), then unchecking the Actors checkbox will have no effect, and posts from the Actors category will be still included.

Actors + Female yields all results, as Actors match any of them. Same happens with Actors + Male, or even if only Actors is selected.

Female will return all posts categorized as Female, even if Actors is not selected. Same happens with Male.

All terms must match exactly logic

This is the most strict logic, only recommended when using a small number of categories. In this case, all of the selected terms must match exactly the result terms, no overlapping/subset matches are allowed.

Selecting all categories will yield no results, as none of the results match Actors, Female and Male categories at the same time. Same will happend when choosing Female + Male.

Actors + Female shows anything matching both of the categories (similarly to the default logic). The same is true for Actors + Male.

Choosing Female only, yields the same results.

Last updated

Copyright Ernest Marcinko