SearchWP Blog

WordPress Tutorials, Tips, and Resources to Help Grow Your Business

How to limit search to specific Post Type

When it comes to limiting search to specific post types, you might run into a bit of trouble.

That’s because it usually requires extensive coding experience, since there is no such feature in WordPress by default.

However, with the right plugin, you can easily filter post types from your website search feature without touching a single line of code or hiring a developer.

In this article, we’ll show you the easiest way to limit search on your site to specific post types with no coding needed.

Why Limit Search to Specific Post Types in WordPress

Limiting searches to certain types of posts on your site brings many advantages.

One of them is it allows you to deliver more relevant search results to your visitors, making their user experience better.

For example, if you run a cooking blog, you can limit the search on your site to only recipes to make it easier to browse your site.

an example of a custom post type

In addition, limiting search on your site to a certain post type will help you boost your content discoverability. If visitors quickly find what they were looking for on your site, then it encourages them to explore more of your content.

Similarly, it also increases engagement and encourages users to stay longer on your site. As a result, you might see an improvement in WordPress SEO.

Besides that, limiting search results can increase your conversion rate. If you’re an eCommerce site owner, then you can restrict each search on your site to products only to make it easier to browse your store and increase the revenue.

Now that you know why to limit the search on your site to specific types of posts, let’s see how you can do that.

How to Limit Search to Specific Post Types in WordPress

The easiest way to limit search to specific post types in WordPress is to use a plugin like SearchWP.

SearchWP

SearchWP is the best WordPress search plugin on the market, with over 50,000 active installations.

Using it, you can limit search on your site to specific post types in just a few clicks, no coding needed.

But this is not the only thing you can do with this plugin. In fact, SearchWP allows you to get complete control over how search works on your site.

For example, you can prioritize specific search results, display search results in live mode, and more.

Here are some other SearchWP features that will help you to make search on your site better:

  • Make custom fields searchable: Use custom post types to publish your content? There is a lot of useful data within their custom fields, which you can make searchable with SearchWP.
  • Add custom search forms: Looking for a way to put a search form inside the post or page? Using SearchWP, you can add a customized search form using the Gutenberg block or shortcode and place it anywhere in your article.
  • Exclude specific pages from search results: Want to hide some posts or pages from search results on your site? With SearchWP, you can do that with just a few clicks.
  • Track searches on your site: Would you like to track your visitors’ searches? SearchWP collects data on all search activity on your site so that you can learn more about your audience.

Now that you know why using SearchWP is the easiest way to limit search on your site to specific post types, let’s see how you can do that below.

Step 1: Install and Activate SearchWP

The first step is to head to the SearchWP website and signup for a new account.

Once you’ve subscribed to a pricing plan and create a new account, the next step is to download the plugin files.

You can find the plugin by logging into your SearchWP account area and go over to the Downloads tab.

Download SearchWP plugin from account area

Once there, you can press the Download SearchWP button to begin downloading the plugin’s ZIP file to your computer.

When you’re finished downloading, copy your license key on the same tab. You’ll need it to activate your SearchWP license a bit further.

The next step is to upload the downloaded file to your site and install the plugin.

Not sure how to do that? You can follow this step-by-step guide on how to install a WordPress plugin.

After the plugin installation, you will see the SearchWP welcome screen and setup wizard. Go ahead and click the ‘Start Onboarding Wizard’ button and follow the onscreen instructions.

Onboarding wizard SearchWP

Step 2: Customize Your Search Engine

Next, you will need to edit the search engine to limit posts on your website.

By default, there is already one search engine called Default. You can customize how search works across your site by editing its setting.

For example, you can exclude from search specific pages or categories, adjust the post attributes’ relevance weight, and more.

Plus, SearchWP allows you to add an unlimited number of search engines and link them to separate search fields. This lets you create customized search forms with a unique set of settings and place them anywhere on your site.

Since we want to limit search to specific post types on our entire site, we’ll customize the ‘Default’ search engine.

Simply head to SearchWP » Algorithm from the WordPress dashboard and click the Sources & Settings button.

Edit or add new search engines in WordPress

Here, you can select which search sources you want WordPress to consider.

By default, all post types are selected as active sources in SearchWP. 

Default search sources

To limit search on your site to a specific post type, you’ll need to uncheck all other sources except it.

For example, we have a custom post type on our test site called tutorials.

Let’s say that we want to limit search to it. To do that, we’ll check this source and leave it as the only active one.

Here is how it looks on our test site:

Select specific post type

When you’ve finished setting up your search sources, simply click Done.

That’s it. Now, search on your site is limited to the selected post type.

The last step is to click the Save button to store the changes you’ve made to the search engine, and then click the Rebuild Index button.

Save and rebuild index

Now let’s try your new search.

Step 3: Test Your New Search Limited to Specific Post Types

To do that, simply visit your website and head to the search form.

For the purposes of this guide, we’ve added a tutorial post type called How to install a WordPress theme in the search bar.

search for a custom post type

As you can see, there are no results except our custom post type, to which we’ve limited search on our site.

The search feature should not show any other post type on the website.

we found our custom post type

To make sure that our search is truly limited to the tutorials, we also tried to search for other post types.

For example, we have a regular post on our site called ‘Why WordPress is the most powerful CMS’.

As you can see, we haven’t found any results.

there are no regular posts in the search results

It means that we successfully limited search on our site to a certain post type.

What’s Next…

In this tutorial, you learned how to limit search to specific post types in WordPress. It’ll help you to give your visitors more relevant search results and improve their user experience.

We hope this article helped you learn how to limit search to specific post types in WordPress. You may also want to see our guide on how to customize your WordPress search results page and how to create a custom search form in WordPress.

In this article, you learned how to limit search to specific post types in WordPress. It’ll help you to give your visitors more relevant search results and improve their user experience.

Ready to create a better and more personalized WordPress search experience? Get started with SearchWP today!

author avatar
Aazim Akhtar

Create a Better WordPress Search Experience Today

Never lose visitors to unhelpful search results again. SearchWP makes creating your own smart WordPress search fast and easy.

Get SearchWP Now
Multiple Search Engines Icon