Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Search By Category in WordPress (Best Method)

It’s frustrating to know that your content is excellent, but your WordPress site’s search shows everything mixed together.

We’ve seen this happen countless times across different WordPress sites. A visitor searches for “email marketing” and gets results from every category – web design tips, SEO tutorials, and social media guides all jumbled together.

Instead of finding what they need, they get confused and click away.

When visitors are able to search within categories, they can find what they need faster and stay on your site longer. On content-heavy sites, like blogs or online stores, this helps boost conversion rates by guiding users straight to what they need.

In this guide, we’ll show you the best method to add category search to your WordPress site. Don’t worry – it’s easier than you might think! 🙌

How to search by category in WordPress (2 ways)

Why Add Search By Category to WordPress?

Categories are an easy way to organize the content on your WordPress website. Categories can also help visitors find interesting posts.

For example, many sites show their categories in a dropdown menu or sidebar.

A list of post categories on the WPBeginner website

If you have lots of blog posts, then you can go one step further and add a search by category feature to your website. This can help visitors find the content they’re looking for, even if you have lots of blog posts.

If you are using WooCommerce, then you can even create a product category search for your online store and get more sales.

Product categories on an eCommerce site

Similarly, if you run a WordPress membership site, then you might use search by category to help visitors find specific members, groups, forums, online courses, and more.

With that being said, let’s see how you can add a search by category feature to WordPress. You can use the quick links below to navigate through this tutorial:

Step 1: Install and Set Up SearchWP

The easiest way to add a category-specific search to WordPress is by using SearchWP. It is the best search plugin and allows you to improve the built-in WordPress search.

With SearchWP, you can search content that WordPress ignores by default, including custom post types, PDF files, WooCommerce products, and categories.

To learn more about the plugin, you can see our detailed SearchWP review.

First, you’ll need to get a SearchWP account by clicking on the ‘Get SearchWP Now’ button on their website. Then, you can simply follow through the registration process.

Is SearchWP the right search plugin for you?

Once logged in, go ahead and grab the SearchWP zip file. You can also copy your license key or keep the tab open for easy access.

Next, let’s install and activate the SearchWP plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, go to SearchWP » Settings and then click on the ‘General’ tab.

Enter SearchWP license key

Here, you need to enter your license in the ‘License Key’ box. You can find this information under your account on the SearchWP site.

Once you are done, make sure to click the ‘Verify Key’ button.

Step 2: Customize Your WordPress Search Algorithm

After activating the plugin, you can fine-tune how SearchWP indexes, searches, and displays your content. You can think of this as creating a custom Google search algorithm that’s just for your WordPress blog or website.

To get started, head over to SearchWP » Algorithm.

The SearchWP search optimization WordPress plugin

Here, you’ll see a section for the different content types that SearchWP searches by default, such as pages, posts, and media files.

Each section has its own Application Attribute Relevance sliders, which allow you to control how SearchWP ranks the content on your website.

For example, if you move the ‘Title’ slider to the middle and the ‘Content’ slider to the right, then the content will carry more weight than the title.

An example of attributes with different relevancy settings in a custom search algorithm

You can even exclude specific pages, authors, and more from WordPress search.

Another option is to include more content in the search results by clicking on the ‘Sources & Settings’ button.

Making more content searchable using SearchWP

You can now check the box next to the different content types. For example, you may want to make blog comments searchable or add PDF indexing and searching in WordPress.

When you are happy with your changes, click on the ‘Done’ button.

How to add comments, media, and more to the WordPress search results

This adds a new section for each new content type. You can now change the attribute relevance using the different sliders.

Once you are happy with how the search is set up, scroll to the top of the screen and click the ‘Save’ button.

Saving your custom WordPress search algorithm

SearchWP will now rebuild the index automatically. Depending on the speed of your Internet connection and your WordPress hosting provider, this may take a few minutes.

As soon as you see ‘Index Status 100%,’ you’ll know that SearchWP has indexed all your content and settings.

Rebuilding your WordPress search index

Step 3: Create a Search by Category Form

At this stage, you’re ready to create a search by category form. This will allow visitors to choose the category they want to search. If you want detailed instructions, you can read our article on how to create a custom search form in WordPress.

First, go to SearchWP » Search Forms. Then, click ‘Add New.’

Adding a custom search form to your WordPress website

Next, give your new search form a name so that you can identify it later. This will come in handy if you decide to create multiple search forms for one website.

Then, choose a layout theme for the search form. Since we’re creating a category-based search form, you should choose ‘Category Search.’

Creating a search by category form with SearchWP

Scrolling down, you will see that the ‘Category Search’ option has been enabled. You can also activate Quick Search (which will give search term recommendations) and Advanced Search (which lets users search using advanced filters).

As for the Engine, you can just select ‘Default’ as that’s what we edited earlier in Step 2.

For the Results Page, you can choose the default WordPress search results page or create a new one using SearchWP. If you’re interested in the second option, then read our guide on how to customize the search results page in WordPress.

Configuring the search form settings in SearchWP

Next, on ‘Type of Search,’ you can select what types of content users can find when using the search engine. If you want this search by category form to only show blog post results, then you can add ‘Posts.’

But if you want to include pages and media files, then go ahead and enter ‘Pages’ and ‘Media.’

In the ‘Select Category’ field, you can include or exclude any blog post categories in the dropdown menu of the search form.

Below that, you can change the placeholder text in the field label and enable or disable the Search Button if needed.

Customizing the search by category form settings in SearchWP

Toward the bottom, you can modify the search form’s border, border color, and font, as well as the button’s shape, label, background color, and font.

Feel free to make the design more suitable for your WordPress theme.

Customizing the SearchWP form's style

Once you’re happy with the search form settings, go ahead and scroll up the page.

Then, click ‘Save.’

Saving the SearchWP form

Step 4: Embed the Search by Category Form in WordPress

Now that you have created a search by category form, let’s embed it on your WordPress website. SearchWP offers an easy-to-use search form block that you can add using the Gutenberg editor, Full Site Editor, and the block-based widget editor.

Let’s try adding the form to a WordPress page. Open the block editor for a new or existing page, and click the ‘+ Add Block’ button.

Then, select the ‘Search Form’ block (not to be confused with the ‘Search’ block, which belongs to WordPress and not SearchWP).

Adding the SearchWP search form block in WordPress

Now, in the ‘Block’ tab in the sidebar, select the form you created in the dropdown menu. You will then see your new search by category form displayed.

Feel free to add more elements to the page, like short instructions or images. Then, click the ‘Publish’ or ‘Update’ button.

Selecting a SearchWP form in the block editor

Now, just preview your WordPress page and see what the form looks like on the front end.

Here is what our search by category form looks like:

Example of a search by category form made with SearchWP

When your WordPress site has a lot of content, it can feel overwhelming for visitors to find exactly what they need. A general search might return too many results, and that frustration can lead them to give up and leave.

A helpful way to fix this is by adding Ajax-powered taxonomy filters, like categories, tags, or custom taxonomies, right next to your search bar. These filters let users narrow down their results in real time, without refreshing the page.

For example, someone might search for “email templates” and then quickly filter by topics like “Marketing” or “Tutorials” to zero in on what they’re really looking for.

Edit search rules

This small change can lead to a much smoother experience, faster results, and happier visitors who are more likely to stay and explore your site. And it’s especially useful for:

  • WordPress blogs with multiple topics or authors
  • Online course libraries, where learners can filter by subject, difficulty level, instructor, or format (e.g., video or text)
  • Directory or membership sites, where members can be filtered by role, expertise, industry, or location
  • Car dealership websites, where users need to search by make, model, year, fuel type, or features
  • Real estate sites, where visitors want to filter by location, property type, or price range

To get started, you can check out our guide on how to add an Ajax taxonomies filter in WordPress search.

FAQs: How to Add Search by Category in WordPress

Got questions about using category-based search on your WordPress site? Here are some common ones to help you get the most out of SearchWP.

Can I use SearchWP with any WordPress theme?

Yes! SearchWP works with all WordPress themes. It upgrades your site’s search functionality without needing any theme-specific tweaks.

Can I customize the appearance of the search by category form?

Absolutely. SearchWP gives you the flexibility to style the category search form so it blends in perfectly with your site’s design. For example, you can tweak your search bar’s label and placeholder as well as change the font and border style.

Is it possible to exclude specific content from being searchable in SearchWP?

Yes, you can. SearchWP makes it easy to exclude certain pages, authors, or content types right from its settings – no extra coding needed.

How to exclude all pages from your site's search results

Additional Resources: More WordPress Search Guides

We hope this article helped you add search by category in WordPress. To learn more about creating a custom WordPress search engine, check out these guides:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

22 CommentsLeave a Reply

    • The SearchWP plugin does integrate with WooCommerce and would allow you to search for products :)

      Admin

  1. Can this guide be followed to create a search for a support site where each category will includes all support posts for a particular services or branch and other for theirs ??
    Thanks for this post.

  2. Hey help , I want to create a search box for web page and it should search in only one page category. How can i do that in wordpress.

  3. This is exactly what I was looking for! Needed a sidebar for a separate review section, with a search bar that only searched that separate section. So this was perfect

  4. Thanks for the support for this awesome plugin. i have tried the plugin, the search by name works fine but the category search is not showing any result. i guess it is not compatible with 3.5 — >3.8.
    i have tried changing “cat” to “category” but all to no avail . Any quick help will be hugely appreciated. Thanks in advance.

  5. After I installed this plugin, the original categories widget doesn’t work any more!
    Once I removed the plugin, it’s work again!
    I still can’t find the reason.

    Could someone tell me how to fix the problem?

    Thanks a lot!

  6. i run both regular search with google custom search, and the search category plugin, . i modified the searchform.php in order to have google search results ( with this shortcode ).
    When i use the search by category plugin the results are the same of the standard so they are not filtered obviously because i use in both case google custom search .
    so i would reset thestandard only for () for this plugin
    how can i Do?
    thanks

  7. Team,

    I tried the steps above, but when i added [sbc] in the text area, it just displayed that as a text instead of calling the search box. Am i missing something here.

    Else, also not sure where i can add the mentioned code in the theme template. Could someone help me with the specific theme file i need to edit.

    Thanks

  8. Oh I’m so glad to find this plugin! I think I need to keep looking though because I need to have it search specific pages on my site as well as some categories of posts.

  9. Search by category is only tested for Wordpress version up to 3.4.2 – is it ok to install anyway? I use 3.5.0
    I really look forward to a functionality which will make it easier for my readers to browse and seach in my categories.
    Greetings Gitte

  10. I just did a review of different options for a client site and eventually installed the Search Everything plugin. It gives you the option to also configure what gets searched. And in this case I wanted to exclude a couple of categories.

  11. If no serious customization is needed, you could just use the following snippet in your searchform.php

    <form method="get" id="searchform" action="<?php echo home_url(); ?>">
    <input type="search" id="s" name="s" />
    <?php wp_dropdown_categories( 'show_option_all=All Categories' ); ?>
    </form>

  12. I use Relevanssi on one of my sites and it is great but I would love to add something like this to narrow search fields but rather than narrow by category. I’d like to narrow by custom taxonomy.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.