SearchWP Blog

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

How to limit search to only posts in WordPress

If you’ve been running a WordPress blog for a long time, then your site’s search results can be cluttered with everything from media files to pages, making it hard for readers to find the blog posts they were looking for.

Sadly, WordPress doesn’t come with a built-in option to filter site searches. You’d have to edit code or hire a developer to customize the default search.

That said, there is an easier way. With SearchWP, you can make your site’s search function exactly how you want it to.

In this article, we’ll show you how to limit search to only posts in WordPress.

Why Limit Search to Only Posts on Your Site?

By default, WordPress displays all published pages, posts, and custom post types in search results.

That’s why sometimes it might be challenging to find the right piece of content, especially on sites with a bunch of pages.

Have you ever used a search form on a site and come across pages like Sitemap, About Us, Checkout, and other similar page among the regular results? Then you know this feeling.

If you’re a blogger, then limiting search results to posts only will make it easier for your visitors to find the content they’re looking for.

It ensures a better user experience and increases engagement. Besides, satisfied users who found the right content on your site are more likely to return again and become the loyal audience.

If you are an online store owner, then technical pages in search results can distract your customers from searching for products.

Removing these pages can improve conversion and make your store look more professional.

That said, let’s see how you can limit the search on your WordPress site to only posts.

Limiting Website Search to Only Posts in WordPress

The easiest way to limit search to only posts in WordPress is to use a plugin like SearchWP.

SearchWP

Used by over 50,000 sites, SearchWP is the best WordPress search plugin. Using it, you can limit search on your site to only posts, pages, or custom posts types in a few clicks, without writing any code.

You also get pre-built form templates that are easily customizable. The best part, you can create unlimited search engines and link them to individual search forms to filter the results on your site.

Some of its other features also include:

  • Keyword Stemming: Do you want to make your WordPress site recognize that search terms like “search” and “searching” are relevant to the same content? SearchWP allows you to enable search for matches related to the keywords you enter, just like in Google.
  • Custom Fields Indexing: The native WordPress search engine doesn’t consider any data stored within the custom fields. It makes it impossible to search on sites that actively use custom post types properly. SearchWP allows you to tackle this issue and make custom fields searchable in a few clicks.
  • Search Activity Tracking: Wonder what your visitors are searching for on your site? SearchWP gives you a full report on your visitors’ search behavior so you can better know your audience and meet their content needs.
  • Seamless Integration: SearchWP offers powerful extensions that allow you to integrate it with popular eCommerce platforms like WooCommerce, form plugins like WPForms, and custom fields plugins like Advanced Custom Fields (ACF).

Now, let’s proceed to the step-by-step tutorial on limiting search to only posts using the SearchWP plugin.

Step 1: Install and Activate SearchWP in WordPress

The first step is to grab your copy of SearchWP by visiting the website and signing up for a new account.

After that, you can navigate to the Downloads tab in your SearchWP account. Once there, simply press the Download SearchWP button and save the plugin to your computer.

Download SearchWP plugin from account area

After you’ve downloaded the plugin, also copy your license key, as you’ll need it soon to activate your license.

Then, go to your WordPress site dashboard and upload the SearchWP plugin ZIP file. Need help with that? Please check out this guide on how to install a WordPress plugin step-by-step tutorial.

After installing and activating the plugin, you’ll see the SearchWP setup wizard. You can click the ‘Start Onboarding Wizard’ button and follow the onscreen instructions.

Onboarding wizard SearchWP

That’s it. You’ve successfully added SearchWP to your site. Now, you can fully use it to improve search on your site.

Step 2: Customize the WordPress Search Engine

Next, you can start customizing your WordPress search engine and limit the search to posts only.

Think of a search engine as a set of rules that you can edit to control how search works on your site.

To get started, you can navigate to SearchWP » Algorithm from the WordPress dashboard. Here, you can customize your default search engine and add new ones.

From here, you can click the ‘Sources & Settings’ button.

Edit or add new search engines in WordPress

Next, a popup will open where you can see the sources for the default search engine.

These include Posts, Pages, and Media.

Default search sources

Now, to limit search to only posts, let’s just remove any other sources from the default search engine source list. This way, your search engine will consider only posts when performing a search.

Simply uncheck the sources you’d like to remove. In our case, let’s uncheck Pages and Media, to leave Posts as the only active source.

Select posts as only source

After you’ve finished, click Done.

Next, you can add or remove content attributes for the Posts source from your WordPress search engine.

Attributes are the fields you want to search for a given source, like title, content, excerpt, slug, custom fields, taxonomy terms, and more. This decides which content details to consider when your site is looking for results.

Go ahead and click the ‘Add/Remove Attributes’ button.

Add attribute for post

A new window will now open with attributes like title, content, slug, and excerpt already selected.

Next, you can include any custom fields, categories, and tags as attributes as well. Simply click the respective dropdown menus and select additional attributes.

For example, if you have a food blog and have created an ACF custom field for ingredients, then you can include that in the search process.

Add custom fields to search

When you’re finished, simply click the ‘Done’ button.

Next, you can click the Save button in the top right corner to store your changes.

Save engine settings

That’s it. You’ve now successfully limited search on your site to posts only.

Step 3: Test Your New Search

Now, let’s test our customized search engine. For the purposes of this tutorial, we’ve created a post and page, both entitled ‘WordPress.’

In the parentheses next to their titles, we indicated what type of content they belong to. It allows us to find out whether the search restriction works or not.

the wordpress post

Now, let’s go over to our demo website and check what search results we’ll get after searching for WordPress.

As you can see, there is no “WordPress (Page)” among the search results. Do note that we’re using the SearchWP Live Search feature, which displays search results as you type in the search form.

the search results

It means that we’ve successfully excluded all types of content from search results, except for posts.

What’s Next…

You can now create multiple search engines and configure them to search for only pages or products.

The best part is that SearchWP lets you link each engine with a specific search form.

This way, you can set up custom searches for different parts of your website. For example, the search in the blog section will only look for posts, while the search in the online store section will only search for products.

Select new engine for form

To learn more, please see our guide on how to add multiple search forms to your WordPress site

We hope this article helped you learn how to easily limit search to only posts in WordPress. You may also want to see our guide on how to add a search bar in WordPress and how to fix WordPress search not working.

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