Categories can help you organize content on your site, but there are situations when you don’t want users to find specific categories.
For instance, you might have sensitive content or want users to only find products from a certain category.
Sadly, there is no way to hide categories by default because WordPress search has many limitations.
In this article, we’ll show you how to exclude any category from search results on your site in a few clicks.
Why Exclude Category from WordPress Search
There are a couple of possible reasons why you might want to hide some categories or pages from search on your site.
To begin with, it helps your visitors to find what they’re looking for faster.
Let’s assume you have the news section on your blog. News blends in with regular blog posts in search results, making it harder to find the right content.
Let’s say you’re an eCommerce WordPress site owner. You’d prefer to exclude non-product categories from the search so that nothing distracts your customers from shopping.
Another reason why you might want to hide certain categories from showing up in search results is sensitive content.
Imagine that you have a category with content accessible only to a certain group of visitors. If anyone can find it using a search, it barely makes any sense.
Now that we know why it might be beneficial to hide specific categories from search results, let’s look at how you can do that.
How to Exclude a Category from WordPress Search Results
The easiest way to exclude a category from search results on your WordPress site is to use a plugin like SearchWP.
Trusted by over 50,000 WordPress site owners, SearchWP is a powerful and easy-to-use plugin allows you to fully customize how search works on your site.
Specifically, you can use it to exclude or prioritize specific search results, make searchable custom post types, track searches, and many more.
SearchWP also improves your site search by helping you:
- Limit search to only posts: Would you like to limit the search on your site to only posts? Using SearchWP, you can do that within minutes, no coding needed.
- Add a search bar to your site. Looking for a way to add a search bar to your site without coding? There are 4 different ways to do that in a few easy steps with SearchWP.
- Create custom search forms. Want to create a fully customized search form that meets your needs? SearchWP allows you to create multiple customized search engines and link them to separate search forms.
- Enable fuzzy search. Do you want WordPress to search for partial matches when there are no full ones? With SearchWP, you can enable this feature just by ticking a checkbox.
Now, let’s take a look at how to exclude a category from search on your WordPress site using the SearchWP plugin.
Step 1: Install and Activate SearchWP
The first step is to grab your copy of SearchWP. Simply visit the website and create a new account.
After that, you’ll need to open your SearchWP account and navigate to the Downloads tab.
Then, press the Download SearchWP button to start downloading the plugin’s ZIP file to your computer.
After completing the download, you can also copy the plugin license key in the bottom left corner on the same tab. You’ll need it further to activate your copy of SearchWP.
The next step is to upload the downloaded SearchWP ZIP file to your site. For more details, please see this guide on how to install a WordPress plugin step-by-step.
Upon activation, you will see the setup wizard. Simply click the ‘Start Onboarding Wizard’ button to configure the plugin.
Once you’ve activated SearchWP, you’re ready to start setting up your search engine.
Step 2: Customize Your Search Engine
To get started, you can go to SearchWP » Algorithm from the WordPress dashboard.
Here you can manage your search engines created with SearchWP.
By customizing search engine settings, you can specify how WordPress should perform searches.
For example, you can add or remove search sources, adjust attribute, set conditions for showing entries, and much more.
Currently, there is only one search engine called Default. WordPress uses it to perform searches across the entire site. It means that any changes you make in its settings will be automatically applied to every search form on your site.
SearchWP allows you to create multiple search engines with a different set of rules and link them to specific search forms.
You can also edit the sources of the search engine by clicking the ‘Source & Settings’ button.
When you’re finished, simply click the Done button.
Next, you can hide categories from WordPress search by adding rules.
For example, let’s say you want to exclude categories from posts. Simply navigate to ‘Posts’ and then click the Edit Rules button.
There are no rules by default, so you’ll need to add the first one.
Go ahead and click Add Rule.
Then, choose the Exclude entries if option from the top-left drop-down menu.
Make sure you have the Categories taxonomy selected, and enter the names of the categories you want to exclude in the very right field.
For example, we’ll exclude the News post category on our test site.
When you’re finished adding categories, press Done to apply the rule.
Then, scroll to the top and click the Save button at the top right to save the changes you’ve made.
That’s it. You’ve successfully excluded a category from appearing in search results on your site.
The final step is to try out your new search engine.
Step 3: Test Your New Search
To do that, simply visit your website and access the search bar.
To test how search works on our test site, we’ve added the New features announcement post and added it to the News category.
Let’s try to search for it.
As you can see, there is nothing found.
It means that posts from the News category no longer appear in search results.
We hope this article helped you learn how to exclude category from WordPress search. You may also want to see our guide on how to track searches on your WordPress site and how to add a search form to your WooCommerce shop page.
If you’re ready to get complete control over how search works on your site, then you can grab your copy of SearchWP here.