How to Exclude Pages from WordPress Search Results?


Do you want to learn the way to exclude pages from WordPress search results?

The WordPress search displays all the pages and posts by default whenever any user searches on your WordPress site. Most of the viewers seek the posts rather than pages. In such a case you need to exclude some of the content so they don’t appear in those searches. 

Luckily, there are different ways to tackle the situation. In this tutorial, we have beautifully mentioned the ways to exclude pages as well as the reason to do so.

Why Exclude Pages from WordPress?  

By default, WordPress displays all the pages and posts in the search results. There are various reasons to exclude pages. The main reason to do so is to hide the private pages of specific users. 

Also, if you are the owner of the online market then you would not reveal your account page, check-out page, etc. In addition to this, this case is useful whenever you want to avoid irrelevant pages from displaying. 

However, this solution allows the user to access the content easier and quicker. Without delay, let’s go through the steps to exclude pages from WordPress search results.

Ways to Exclude Pages from WordPress Search Results

Here we have mentioned two easiest ways to exclude pages:

1. Using a Plugin

The use of the plugin is the easiest method to exclude pages. There is no risk of any problems as well as the fall of the website using plugins. Plugins are easy to install and immediately start working only after some configuration. 

Check Exclude is the plugin that is used to create a lightweight and easily accessible websites. This plugin does not need any configuration. Additionally, this adds a new feature in the editing area of the posts or pages.

Note: The sitemap of your site will contain the page you have excluded as well as it doesn’t support quick and bilk edit. 

Follow the steps mentioned below:

  • Install and activate the plugin Search Exclude.
Exclude pages from WordPress search results.
  • After activation, open any page or post you would like to exclude. You will find a checkbox on the right side titled “Search Exclude“. Check the box if you wish to remove it from search results.
  • Simply save or publish the content in order to see the result.
  • Head to Settings >> Search Exclude where you will find the lists of the pages or posts you have excluded.  

Hence, you have successfully excluded your pages from search results.

2. Adding Code in Functions.php File

This is the shortest method but be careful while adding the code because a small error can cause the downfall of the entire site. You can go through our article” How to Easily Add Custom Code in WordPress?” to add code in the function.php file without having the risk of breakdown of the site.

In this method, all you need o do is add code to your function.php file to remove the pages. Copy and paste the code mentioned below into your Code Snippets:

function SearchFilter($query) {

        if ($query->is_search) {

                  $query->set(‘post_type’, ‘post’);


      return $query;



Save and activate the code.

Thus, in this way you have excluded pages or posts from your WordPress site.

Wrapping up

We hope all your queries are answered through this article. Although we have mentioned the two easiest ways to exclude pages, you can follow the method which suits your requirement. If you have any confusion regarding this topic please feel free to ask in the comment section.


Please enter your comment!
Please enter your name here