SearchWP

News

how to exclude category from WordPress search

Do you want to know how to exclude category from WordPress search?

There is no way to do that by default because WordPress comes with weak search customization options.

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.

Or, here is another example. Let’s say you’re an eCommerce WordPress site owner.

You’d prefer to exclude non-product categories from 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.

SearchWP logo

Trusted by over 30,000 WordPress site owners, this 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:

  • 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.
  • 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.

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 here.

After that, open your SearchWP account and navigate to the Downloads tab.

go to the Downloads tab

Then, press the Download SearchWP button to start downloading the plugin’s ZIP file to your computer.

press Download SearchWP

After completing the download, 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.

copy your license key

The next step is to upload the downloaded SearchWP ZIP file to your site.

Need a refresher on how to do that? Check out the how to install a WordPress plugin step-by-step guide.

Upon the plugin installation, navigate to your WordPress dashboard and click SearchWP at the top bar.

go to the SearchWP settings

Then, go over to the License tab.

navigate to the License tab

Paste your license key copied earlier into the License field and press Activate.

click Activate

Once you’ve activated your copy of SearchWP, you’re ready to start setting up your search engine.

Step 2: Customize Your Search Engine

To get started, go over to the Engines tab.

go to the Engines tab

Here you can manage your search engines created with SearchWP.

the list of your search engines

By customizing search engine settings, you can specify how WordPress should perform searches.

For example, you can add or remove search sources, adjust attribute relevance weights, 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.

But, as we want to hide a category from search results globally, we’ll be editing the Default search engine.

To get started, click on the Posts search source to expand its settings.

click Posts

Then, press the Edit rules button.

click Edit Rules

There are no rules by default, so we’ll be adding the first one. To do so, click Add Rule.

press Add Rule

Then, choose the Exclude entries if: option from the top-left drop-down menu.

choose exclude entries if

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.

add a category you want to exclude

When you’re finished adding categories, press Done to apply the rule.

click Done

Then, click the Save Engines button at the top right to save the changes you’ve made.

press Save Engines

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, press the Visit Site button under your site’s name at the top left of the WordPress dashboard.

press Visit site

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.

press Find results

As you can see, there is nothing found. It means that posts from the News category no longer appear in search results.

no results found

In this article, you learned how to exclude category from WordPress search.

If you’re ready to get complete control over how search works on your site, you can grab your copy of SearchWP here.

Would you like to know what visitors were searching for on your site? Check out the how to track searches on your WordPress site guide.

Came across any search errors on your site? Follow the how to fix WordPress search not working tutorial to learn how to deal with the most common issues.

Want to make your search awesome right now?

More than 30,000 sites have chosen SearchWP!

You can utilize all of the content that’s gone unrecognized by native WordPress keyword search instantly with SearchWP.

Get SearchWP for just $99

  • Committed Support
    If you need help, support is fast, friendly, and here for you
  • Streamlined Setup
    Installation and setup that’s optimized for speed
  • Great Documentation
    Helpful, clear, and usable documentation is a priority

See what SearchWP customers have to say

  • “We needed to index a website with lots of page content and woocommerce products. SearchWP delivers a lot of useful default functions and setting up was easy with the help of the extensive documentation.”

  • “SearchWP plugin integrates well with other plugins, is well coded and performs well. Good investment.”

  • “SearchWP delivers the search experience WordPress should out of the box. The way it combs through Advanced Custom Fields (ACF) is class leading. It’s an excellent product and a terrific value.”