Header Ads Widget

How to Search By Category in WordPress (Beginner’s Guide)

How to Search By Category in WordPress (Beginner's Guide)

So, you’ve spent a lot of time carefully organizing your content into categories?

Bad news: the built-in WordPress search bar completely ignores categories. 

This can be disastrous for the user experience. Imagine someone searching for ‘Protein Powder’ on your fitness blog because they want a specific product review. Instead of seeing your ‘Reviews’ category, they get a cluttered list of every workout and recipe post that happens to mention protein.

Most visitors won’t stick around to hunt for the right link. They’ll simply leave your site and look for answers elsewhere.

Adding a category filter to your search bar completely changes that experience. It gives your audience a shortcut to the content they actually care about.

Whether you’re running a membership site, a busy blog, or an online shop, this small change helps visitors find what they need faster. In this tutorial, I’ll show you how to quickly add ‘Search by Category’ to your WordPress site, without writing a single line of code.

Why I Add Search By Category to My WordPress Site

Before I show you how to upgrade your site’s search, I want to explain why this small change makes such a big difference. I’ve added category search to several of my own sites, and I’m always surprised by how much it helps visitors find exactly what they need.

In my experience, there’s several major benefits to adding category search to your WordPress website:

  • Improves the User Experience: When someone visits a site that covers a wide variety of topics, they usually have something very specific in mind. Imagine you run a lifestyle blog. In this scenario, a reader who’s interested in your ‘Healthy Eating’ section shouldn’t have to sift through your ‘Home Decor’ or ‘Travel’ tips just to find a salad recipe. By adding a category dropdown, visitors can find the content they want in seconds rather than minutes. 
  • Less Bounce, More Engagement: If a visitor searches for something and gets a wall of irrelevant results, they’re most likely going to leave your site (this is called a ‘bounce’). By adding a category search, you help those visitors find exactly what they need on the first try. As a result, they stay on your site longer, explore more pages, and feel like your website actually works for them.
  • A Better Experience for Niche Sites: If you run a directory, a course library, or a membership site, this feature is a lifesaver. A reader on a real estate site can search only for ‘Rentals,’ or a student can search only for ‘Lessons.’ This kind of focused experience is exactly what people expect from a modern, professional website.
  • Smarter Than the Default WordPress Search: The built-in WordPress search is very basic. In fact, it only looks for keywords and doesn’t understand your site’s structure. It can’t filter results by category or prioritize one type of content over another. By adding a smart search plugin, you’re giving your site the intelligence it needs to respect your structure and deliver the right results every time.

Step 1: Install and Activate SearchWP

The easiest way to add a ‘search by category’ feature to WordPress is by using SearchWP. For years, I’ve used this plugin to create all kinds of advanced search bars, ranging from user-friendly category dropdowns, right through to complex searches that scan across custom post types.

Every SearchWP plan allows you to search by category, including the Basic license ($99/year), so you can simply choose the license that makes sense for you. 

How to improve the built-in WordPress search with an advanced search plugin

Once you’ve purchased your SearchWP license, the next step is to install the plugin on your site. 

If you’ve never installed a WordPress plugin before, don’t worry! Our beginner’s guide on how to install and activate a plugin will walk you through the process, step-by-step. 

Step 2: Add Your License Key

With the plugin active, the next step is adding your license key. 

In your WordPress dashboard, go to SearchWP » Settings

Adding a license key to the SearchWP advanced search plugin for WordPress

You can now go ahead and add your key into the ‘License Key’ field. You can find this information in the email you received when you bought SearchWP, or by logging into your account on the SearchWP website. 

With that done, click the ‘Verify Key’ button. 

Step 3: Choosing What Your Site Actually Searches

This is where SearchWP separates itself from the standard WordPress search bar.

Instead of a one-size-fits-all algorithm that you can’t control, SearchWP provides a user-friendly dashboard where you can customize the logic behind your search results. This allows you to fine-tune how your site handles every query, so visitors can always find exactly what they’re looking for.

To make these changes, go to SearchWP » Algorithm

Creating a custom search algorithm for your WordPress blog or website

In SearchWP, search engines are essentially sets of rules that tell WordPress how to perform a search. You can create separate engines for different parts of your site, such as a ‘Staff Directory’ search that only looks through names and job titles, or a ‘Resources’ search that exclusively scans through your PDF library.

To start, you’ll see a single engine called ‘Default.’ This controls the main search box on your site, so we’ll be focusing on it throughout this guide.

Out-of-the-box, the Default engine searches your pages, posts, and media files. However, you can change these content sources to better fit your needs. For example, you might remove media files to prevent random images from cluttering your results, or you might add WooCommerce products so customers can find items to buy. 

To add more content types, click the ‘Sources & Settings’ button.

Adding a 'search by category' dropdown menu to your blog, website, or online store

You’ll now see all the different content types across your site. The options you see may vary depending on whether you’ve installed additional plugins like WooCommerce or created your own custom post types. 

No matter what appears, you can include or exclude content simply by checking or unchecking its box.

Creating a custom search algorithm (like Google) for WordPress

When you’re happy with your selection, click ‘Done’ to close the popup.

Step 4: Adjusting the Applicable Attribute Relevance

With your sources selected, it’s time to look at the ‘Applicable Attribute Relevance’ sliders within each content type. Each slider controls a specific attribute, like the Title, Content (the body text), Slug, or Excerpt. 

Controlling how items appear in search results

When you move a slider further to the right, you’re telling SearchWP that words found in that area are more important than others. This means they’ll have a bigger impact on the search results.

When you move a slider to the left, you’re telling SearchWP they’re less important, and should therefore have less impact on the search results. 

Let’s look at an example: if you move the ‘Title’ slider to the middle and the ‘Content’ slider to the right, then a keyword found in the body text will carry more weight than one found in the title.

Pro Tip: I almost always drag the Title slider all the way to the right for every post type. In my experience, if a visitor types in a phrase that matches your headline exactly, that post is almost certainly what they’re looking for.

Simply go through each content type (Posts, Pages, and any others you’ve enabled) and adjust the sliders, as required. 

Don’t be afraid to experiment here. You can always return to this screen and adjust the settings until you’re happy with the results. 

Step 5: Add Categories to Your Search Engine

Next, you need to tell SearchWP that it should take a post’s category into consideration when performing a search. 

To do this, click the ‘Add/Remove Attributes’ button inside the ‘Posts’ section. 

Making additional attributes searchable on your website, blog, or WooCommerce store

In the popup that appears, find the ‘Taxonomies’ field. 

Start typing ‘Categories’ into this field, and then select the correct option when it appears in the dropdown menu. 

How to make categories searchable in WordPress

With that done, click ‘Done’ to close the pop up.

‘Categories’ will now appear as a new item in your list, complete with its own ‘Applicable Attribute Relevance’ slider.

You can now adjust this slider by dragging it to the right (to make it more important) or to the left (to make it less important). I usually move the slider to the center. This creates a nice balance where a category match influences the search results, but doesn’t completely overwhelm exact title matches.

Marking attributes as more, or less important in the search results

Step 6: Rebuild the Search Index

Once you’re happy with how everything is set up, don’t forget to click the ‘Save’ button. 

Saving your custom search algorithm in WordPress

Instead of searching your live pages every time a visitor types a word, SearchWP instead looks at a saved index and delivers its results instantly. Once you’ve changed your settings, you need to rebuild this index so SearchWP can re-scan your site and apply the new rules.

To do this, just click the ‘Rebuild Index’ button. 

How to rebuild the search index on your website, blog or eCommerce site

This may take a few minutes depending on the speed of your internet connection, your WordPress hosting provider, and how much content you have. 

When it’s finished, SearchWP will display an ‘Index Status 100%’ message. Your new category-aware search is ready to use. 

How to rebuild the index on your WordPress blog or website

If you ever make a massive change to your site (like deleting a hundred old posts or significantly changing your category structure) I recommend coming back to this page and rebuilding the index.

While SearchWP does an excellent job of updating itself as you go, a manual refresh ensures your search results are perfectly accurate and up-to-date straight away.

Step 7: Create Your Search by Category Form

Now, you’re ready to build the actual search form visitors will interact with. The good news is that SearchWP includes its own form builder, so you don’t have to worry about writing code or wrestling with complicated settings.  

In your WordPress dashboard, go to SearchWP » Search Forms and click the ‘Add New’ button.

How to create a custom search form

This opens the form builder, where you can customize exactly how your search bar looks and behaves.

By default, SearchWP gives the form a generic name like ‘Search Form 1.’ I highly recommend clicking the pencil icon and renaming it to something more descriptive, like ‘Category Search’ or ‘Blog Sidebar Search.’

How to create a customized WordPress search form

I once helped a site owner who had created six different ‘Search Form 1’ variations for different pages. It was a nightmare trying to figure out which one was which! Taking five seconds to rename the form now will save you a massive headache later when you’re trying to update your site.

Next, you can choose a layout. SearchWP actually comes with a dedicated ‘Category Search’ layout, which is a huge time-saver. You can simply go ahead and click this theme to select it.

Choosing a layout for your custom search form

After picking your layout, scroll to the ‘Custom Styling’ section and click the toggle for the ‘Category Search’ slider. 

This adds an extra dropdown menu to your search bar, so visitors can filter their results by specific categories.

How to add a category dropdown to your search bar

Finally, check the ‘Engine’ field, as this tells the form which set of rules to follow.

Since we customized the ‘Default’ engine, you’ll want to make sure it’s selected. 

Improving the default WordPress search with additional dropdown menus

Step 8: Declutter Your Category Search

By default, SearchWP includes every category in its dropdown menu. However, you may not want to show every single category to your visitors. For example, you’ll typically want to hide ‘Uncategorized’ or any internal categories you’re using like ‘Admin Notes’ or ‘Archive.’ 

To clean things up, scroll to the ‘Select Category’ field. To exclude a category from the list, simply click the ‘X’ icon next to its name.

Adding category search to WordPress

If you change your mind later, re-adding a category is just as easy. 

Simply start typing the category’s name into the same field. When the right option appears in the list, click to re-add it. 

Adding and removing categories from your custom search

Once you’re happy with the category selections, click the ‘Save’ button to store your changes.

Congratulations! You’ve just built a smart, filtered search tool that’s far more advanced than the standard WordPress search bar.

Excluding taxonomies from your category search

Step 9: Embed the Form on Your Site

A ‘Search By Category’ form doesn’t help anyone if it’s just sitting in your dashboard! In this final step, I’ll show you how to place the form on your site so visitors can actually use it.

SearchWP gives you a few different methods, but the easiest is to use the built-in SearchWP block, so that’s the method I’ll be covering first.

  • Using the SearchWP From Block 

SearchWP comes with a dedicated block that lets you add a search bar to any page, post, or widget area. This is a good option if you want to create a custom search page or give visitors a way to search within a specific section of your site, like a members-only area, customer support portal, or storefront.

Simply open the page or post where you want to display the search form. Then, click the ‘+’ button and start typing ‘SearchWP Form.’

When the right block appears, click to add it to your layout.  

Adding a custom search form to your website

Next, open the dropdown menu and select the form we just created.

SearchWP will immediately show a preview of how the form looks, including that handy category dropdown.

Placing a custom form on your WordPress website

You can then go ahead and either publish or update the page as normal, in order make your ‘Search By Category’ form live.

Pro Tip: If you’re building a dedicated search page, I suggest adding a little bit of introductory text above this block, such as “Not sure where to start? Pick a category below.” In my experience, giving users a small nudge or instruction can increase search engagement.

  • Using Shortcode 

While blocks are my go-to method, sometimes you might need to add a search bar to a location that doesn’t support them, such as a specific template file or an older sidebar widget. 

Thankfully, SearchWP has you covered: every time you create a form, the plugin automatically generates a dedicated shortcode for it.

To find this shortcode, go to SearchWP » Search Forms. Simply find the form you want to display and copy its accompanying shortcode. 

How to add shortcode to your WordPress blog or website

You can now paste it into any location that supports shortcodes. If you’re using the WordPress block editor but still prefer the shortcode method, then you can even paste it into a Shortcode block.

Step 10: Test Your New Search by Category

Before we wrap up, it’s always a good idea to test your new search form, just to make sure everything is working as expected.

Simply visit your live site and head to the page where you embedded the form. You should see your new search bar complete with the category dropdown we configured.

An example of a Search By Category dropdown, created using SearchWP

To test it, open the dropdown menu and select a specific category. Then, type in a keyword or phrase that you know exists in an article within that category, and hit enter. 

The search results page should now display only the posts that match both your keyword and the selected category. 

An accurate search results page

To be 100% sure everything is linked up correctly, try searching for that same keyword again. However, this time leave the category dropdown set to ‘All Categories.’ 

You should see a much broader list of results from across your entire site. If you see that difference, congratulations – your dropdown is working perfectly!

If you perform a test search and see ‘No results found’ (even though you know the post exists), don’t panic. This typically means SearchWP hasn’t applied all the new category rules yet. Just head back to SearchWP » Algorithm and click ‘Rebuild Index’ to force a fresh rebuild. This should fix the problem. 

How to rebuild the search index in WordPress

It’s as easy as that! You’ve successfully moved past the limited default WordPress search and given your visitors a professional, category-aware tool to explore your content.

Getting Even More Out of SearchWP

Now that your category search is up and running, you might want to add some finishing touches. While the basic setup works great, there’s a few extra steps you can take to make your search feel even more professional.

Add Live Ajax Search for As-You-Type Suggestions

One of the best ways to make your site feel modern is by adding live results. This is one of my favorite search features, and I add it to almost every site I build.

With Live Ajax Search, your visitors don’t have to wait for a new page to load. Instead, results appear instantly in a dropdown menu as they type, just like Google’s autocomplete. This helps visitors find exactly what they need, faster.

Even better, you can add this feature to your site for free by installing SearchWP Live Ajax Search

The live Ajax search WordPress plugin

It’s designed to work perfectly with the core SearchWP plugin, without requiring any extra setup. Once you activate it, live search is automatically added to all your forms, including the search-by-category form you just created.

Track What Visitors Are Searching For

Monitoring your site’s search is one of the best ways to understand your audience, and improve their experience. 

First, it helps you fine-tune your results. For example, if you notice visitors are searching for a specific term but consistently clicking the third or fourth result, you should tweak your Attribute Relevance sliders to make this content easier to find.

Beyond just technical tweaks, this data is also a valuable source of new content ideas. It may reveal content gaps, which are topics your visitors are clearly interested in, but your site doesn’t cover yet. For example, if you see visitors searching for a specific tutorial you haven’t written yet, then this is the perfect idea for your next blog post and a chance to improve your WordPress SEO at the same time. 

To see these search analytics, you’ll need to activate SearchWP’s Metrics extension. To do this, go to SearchWP » Extensions, find the ‘Metrics’ section and click its ‘Install’ button.

Installing an analytics extension for your WordPress search

SearchWP will automatically install and activate the Metrics add-on for you. 

Once that’s finished, head to SearchWP » Metrics in your left-hand menu.

Monitoring search behavior on your website, blog, or e-commerce store

You can now see detailed information including the most popular terms people are searching for, click-through rates, and clicks per search. 

Frequently Asked Questions About Search by Category in WordPress

I get a lot of questions about setting up category-based search, and many of them come up over and over again. 

To help you feel more confident, I’ve put together answers to these most-frequently-asked questions, so you can troubleshoot common issues on your own and get the most out of your new search setup.

Is there a free version of SearchWP? 

No, SearchWP is a premium-only plugin. While many plugins offer a lite version, SearchWP focuses on providing a professional-grade search experience right out-of-the-box.

If you aren’t ready to invest in a search plugin just yet, you can try SearchWP Live Ajax Search. This is a free plugin that adds live, ‘as-you-type’ suggestions to your existing WordPress search bars. While it integrates perfectly with the premium version of SearchWP where available, it also works fine without it. 

For basic filtering, Ivory Search is another free alternative worth considering. However, if your site’s success depends on visitors finding content quickly and easily, most users find that SearchWP is well worth the investment because it handles the entire search experience in one easy-to-use tool.

Will this work with WooCommerce product categories?

Yes! If you have a WooCommerce store, you can use the exact same steps to help customers search by product category.

Simply go to SearchWP » Algorithm and click the ‘Sources and Settings’ button. In the popup window, check the box next to ‘Products’ and click ‘Done.’

How to filter WooCommerce products by category using SearchWP

‘Products’ will now appear as a content type on your dashboard. From here, you can adjust the sliders or add specific attributes, just like we did with blog posts. 

It’s one of the best ways to make your shop feel more professional and help your customers find what they want to buy.

Can I change how the search form looks?

Absolutely. One of the best things about SearchWP is that its forms are ‘theme-aware.’ This means they automatically adopt the fonts, colors, and button styles of your current WordPress theme so they look like a natural part of your site straight away.

For most sites, the default settings work perfectly because SearchWP does such a great job of matching your existing design. However, if you want to  make specific changes then you can use the Layout Theme settings inside the form builder. 

How to customize the SearchWP search form

This allows you to adjust things like spacing and colors without needing to write any code. 

Will SearchWP slow down my site?

I get this question a lot, and the short answer is: no, it won’t. In fact, SearchWP is usually faster than the default WordPress search.

This is because SearchWP creates a saved index of your content ahead of time. Instead of scanning your entire site every time a visitor types a word, SearchWP quickly checks its own pre-built list to deliver results instantly. 

While the very first index build might take a few minutes if you have a massive site, everything after that is designed to be snappy and efficient.

Wrapping Up

If you’ve been following along, your visitors can now search by category and find exactly what they need in record time. That’s a massive upgrade!

Of course, a great search experience is just one piece of the puzzle. If you’re ready to keep leveling up, our WP101 video library covers everything from the basics to advanced customization, all explained in plain, simple language.

Sign up for WP101 »

How to Search By Category in WordPress (Beginner’s Guide) appeared first on WP101.com

from WordPress Tutorial Videos by WP101® https://ift.tt/Mt7yIho
via IFTTT

Post a Comment

0 Comments