Knowledge Base

Searching within given categories/taxonomy terms only

There are 2 possible solutions:

Solution 1

On the Advanced Options -> Exclude results panel, with the Include posts only from selected categories/taxonomy terms option.

category-include

If you also want to exclude posts which are uncategorized or not connected with any terms, then go to the Frontend Search Settings -> Advanced panel and turn off the Show posts/CPM with empty taxonomy terms? option

category-include-empty

Solution 2

Using this custom code in your active themes functions.php file:

Make sure to change the $include variable as instructed to the desired taxonomy terms.