When setting up a new WordPress blog, one feature we always prioritize is a search bar. Specifically, a search by category bar.
A category-specific search helps readers find exactly what they’re looking for, keeps them engaged longer, and encourages better content organization. For blogs or online stores, it can even boost conversion rates by guiding users to relevant offerings more quickly.
While adding this feature might seem daunting, it’s actually quite simple with the right tools. In this guide, we’ll walk you through adding a search by category function to your WordPress blog using SearchWP.
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.
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.
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, see our detailed SearchWP review.
First, you need to 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.
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.
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 left and the ‘Content’ slider to the right, then the content will carry more weight than the title.
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.
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.
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.
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.
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.’
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.’
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.
Next, on ‘Type of Search,’ you can select what types of content can users 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.
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.
Once you’re happy with the search form settings, go ahead and scroll up the page.
Then, click ‘Save.’
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).
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.
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:
To learn more about creating a custom WordPress search engine, check out these guides:
- How to Improve WordPress Search with SearchWP (Quick & Easy)
- How to Customize WooCommerce Product Search Results Page
- How to Add a Search Bar to WordPress Menu (Step by Step)
- How to Add Live Ajax Search to Your WordPress Site (The Easy Way)
- How to Add Multilingual Search in WordPress
- How to Include Custom Post Types in WordPress Search Results
- How to Make Custom Fields Searchable in WordPress
We hope this article helped you add search by category in WordPress. You may also want to see our beginner’s guide on WordPress categories vs tags for SEO and our article on how to create custom taxonomies in WordPress.
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.
Syed Balkhi
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Diiamo
Thank you, does it support woocommerce product catalog?
WPBeginner Support
The SearchWP plugin does integrate with WooCommerce and would allow you to search for products
Admin
Mrteesurez
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.
WPBeginner Support
If we understand correctly then yes, you should be able to do that
Admin
Hansan
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.
Eric Thomas
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
philips
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.
Eric
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!
sergio
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
WPBeginner Support
you can not use search by category and Google custom search. You can create two different forms and search templates.
Admin
Srinivas
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
Editorial Staff
Please post all plugin related support in the supports forum:
http://wordpress.org/support/plugin/search-by-category
Admin
Gretchen Louise
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.
mike
Really saved my time a lot ………..
This plugin still works with wordpress 3.5.1 !!!!
Rosca Bogdan
@Alian there is a plugin for that, Query multiple taxonomies.
You can find it @ http://scribu.net/wordpress/query-multiple-taxonomies/ . I use it and it`s working like a charm.
Alan
Can this be used for search results?
Gitte Hansen
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
Editorial Staff
Yes it is fine. It will work.
Admin
Corrinda
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.
Azim
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>
Pam
What would this do for you? tried it but nothing.
Alan
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.