Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Exclude Pages from WordPress Search Results (Step by Step)

When we add a search bar to a WordPress site, we always think carefully about which pages should appear in the results.

Some pages, like your privacy policy, terms of service, or thank you pages, might not be particularly useful in search results. For eCommerce sites, pages such as the checkout or user account pages typically don’t need to be searchable.

In this article, we’ll show you how to exclude pages from WordPress search results, step by step. 

How to exclude pages from WordPress search results (step by step)

Why Exclude Pages from WordPress Search Results?

The default WordPress search includes all your posts and pages in its search results.

However, this may not work well for all websites. For example, if you’re running an online store, then you may want to hide pages like your account page, checkout page, thank you page, and more.

Similarly, if you run membership websites or sell online courses, then you’ll want to stop subscriber-only content from appearing in public search results.

With that said, let’s show you how to exclude pages from the WordPress search results. You can use the quick links below to navigate through this tutorial:

Note: In this guide, we’re focusing on on-site search, where a visitor uses your website’s search box to look through your content.

If you want to exclude pages from Google search results, then you should see our guide on how to hide a WordPress page from Google.

Step 1: Install a WordPress Search Plugin

The easiest way to exclude pages from the WordPress search results is by using the SearchWP plugin. It’s the best search plugin for WordPress used by over 30,000 websites.

With SearchWP, you can search content that WordPress ignores by default, including comments, custom post types, PDF files, WooCommerce products, and categories. You can also exclude content.

To learn more, see our detailed SearchWP review.

The first thing you need to do is install and activate the 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.

Activating the SearchWP WordPress plugin

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: Create a Custom 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.

You’ll need to create a sitewide search engine before you can start excluding pages from the search results, so head over to SearchWP » Algorithm.

Creating a custom search algorithm in WordPress using SearchWP

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 allows you to control how SearchWP ranks the content on your online marketplace, blog, or 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.

Changing the attribute relevancy scale

You can either exclude all pages from the search results, or exclude specific pages only.

To stop all pages from appearing in your WordPress website search results, click on the small trash icon next to ‘Pages.’

Excluding all pages from the WordPress search results

This opens a popup where you can uncheck the ‘Pages’ box.

After that, simply click on ‘Done’ to exclude all pages from the search bar and results.

How to exclude all pages from your site's search results

When you’ve finished customizing the default search engine settings, it’s time to save your changes. Even if you plan to exclude specific pages or posts, you’ll still need to save your new sitewide search algorithm first.

To do this, scroll to the top of the screen and click the ‘Save’ button.

Saving the custom search algorithm using SearchWP

SearchWP will now rebuild the index automatically. Depending on the speed of your Internet connection, 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.

Rebuilding the search index in WordPress

Your site will now start using the improved WordPress search automatically.

Step 3: Exclude Specific Pages From the WordPress Search Results (Optional)

Do you want to exclude specific pages from the search results, such as the WooCommerce checkout page?

After creating a sitewide search algorithm following the process described above, you can exclude individual pages from the search results.

To do this, you’ll use the Exclude UI extension, which adds an ‘Exclude from search’ box to the page editor.

In the WordPress dashboard, head over to SearchWP » Extensions. Here, find the Exclude UI extension and click on its ‘Install’ button.

Installing SearchWP search extensions

After that, open the page that you want to exclude from the search results. In the right-hand menu, make sure the ‘Page’ tab is selected.

You can now go ahead and check the ‘Exclude from search’ box.

Exclude from search checkbox

Then simply click the ‘Update’ button, and this page will no longer appear in the search results. If you want to hide more pages from the search results, then simply follow the process described above.

Step 4: Create and Embed Your Search Form

Now that you have created a custom WordPress search engine that excludes pages, you need to make a search form using that engine.

All you need to do is go to SearchWP » Search Forms and click the ‘Add New’ button. This will create a new search form that you can customize.

Adding a custom search form to your WordPress website

For step-by-step instructions, check out our guide on how to create a custom WordPress search form. This guide walks you through creating and embedding the search form on your pages, posts, and widget-ready areas.

You can also add the search form to your search bar. If you use a classic theme, then you will need to use the SearchWP Modal Search Form plugin.

The SearchWP native search template

If you use a block theme, then you can use the Full Site Editor to add your SearchWP form in the navigation menu.

You can get more detailed information in our guide on how to add a search bar to the WordPress menu.

Bonus Tip: Exclude Posts, Taxonomies, and More from WordPress Search Results

Sometimes you might want to fine-tune your WordPress search results even further to only include specific content. This could be useful for excluding items like private posts, custom post types you don’t want users searching for, or even specific taxonomies like tags.

For instance, excluding tags from search results might be helpful if you use them internally for organization but don’t want them confusing users.

In this case, you can read our guide on how to exclude specific pages, authors, and more from WordPress search.

Another option is to exclude specific page categories from the search results. To do this, you’ll need a clear system for categorizing your pages, which may take some planning. However, you won’t need to install any extra extensions.

To show the pages from specific categories only, please see our guide on how to search by category in WordPress.

We hope this article helped you learn how to exclude pages from the WordPress search results. You may also want to see our beginner’s guide on how to create a custom page in WordPress and the best popular posts plugins for 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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

39 CommentsLeave a Reply

  1. Jiří Vaněk

    I have pages on my website with short pieces of information that unnecessarily clutter search results, as they don’t hold much informational value and are more relevant to the date of publication than anything else. This is a great way to exclude them from search results and guide users to truly relevant information. It works perfectly.

  2. Dennis Muthomi

    Thanks for this step-by-step guide.
    I have excluded the check out page from the search result and it worked!
    This is the best plugin for fine-tuning my site search by far.

  3. Gabriel

    Thanks a lot! Seems to work perfectly.

    • WPBeginner Support

      Glad our guide was helpful :)

      Admin

  4. joel araujo

    just what I needed, at the right time
    thanks

    • WPBeginner Support

      Glad our guide could help :)

      Admin

  5. Ivan

    Thanks. This worked for me. I wanted to exclude gallery appears in search results and this code does exactly what I need. Thanks

  6. Pete

    This is really basic. It would be nice to see how to exclude only particular page templates, or blog categories.

  7. VishvjeetCheema

    You are true life savers. always. :)

  8. Gautam Nagraj

    Hello team WPBeginner

    I am facing a new problem

    when I have tested crawled pages on Google by writing

    site:example.com

    Then it showing pages & posts properly but also showing pagination links

    example.com/page/2/

    Like this

    So how can I avoid this?

    Please help me.

  9. Laura Rafferty

    Wondering if there’s a way to target different search forms with this technique. I’d like the main website search form to target pages only; and the blog search form to target posts only.

  10. Val

    I have some pages that are password protected (via main WP option to password protect a page) but they are still showing up in WP search with the excerpts. My understanding is that by default, the excerpts should not appear, you should see “There is no excerpt because this is a protected post.” I can use the Simply Exclude plugin but I’m wondering why the excerpts are showing up in the first place and I’d rather not add another plugin if I don’t have to.

  11. deny jackrose

    Thank you very much sir.. this post really help me.. you rock man .. !!

  12. Victor

    Thank you very much. You guys did the trick. I was looking for this and couldn’t find it anywhere else.
    Nice job, guys.

  13. Noah

    When someone just hits SEARCH with the criteria being ‘blank’, ALL pages show up in the results. How can I have NO results show in this situation?

    • Jornes

      Noah, if you are saying about search result, you can validate the search form using javascript. So that people are forced to key in the words before do the searches.

  14. Samsir Alam

    Thanks bro.

  15. Dimitra

    Thank you so much for the article and some comments with codes that helped me a lot!

  16. redimin

    Work Fine !

  17. Bruno

    Thanks bro! Your code helped me a lot.

  18. Henry

    This worked much better than passing a hidden field (which is what I’ve been doing).

  19. Laura

    This worked great, thanks! How can I include Wordpress Native BBPress forum topics in the search results?

    Thanks,

    L

  20. Jornes

    Hi! I would like to ask how do i exclude the specified pages i wanted to excluded from searches? And how do i know what is the ID of the page? Can someone tell a solution? I wanted to excluded some pages which are useless to visitors.

    Thank you!

  21. hamza

    works for me. thank you!

  22. Spyridon

    You are a real life saver. I tried codes from WordPress forum but didn’t work out. Yours is working for me! :D

  23. luckyankit

    Well just wanted to say thank you for this… wonderful article

  24. gormanIT

    Can you alter this function to exclude specific pages/posts from search? Ive been searching for this functionality and havent found anything.

  25. David Allred

    Perfect! I was expecting it to be a bit more complex than that. Thanks a ton!

  26. Michael Bailey

    Thank you so much. This was super helpful, fixing my problem with the speed of a cut and a paste (and a test)..

    Success in all your ways!

    Michael.

  27. Katie

    Well, that’s almost perfect. I searched and found that many site’s offering us to hardcode the category ids to search id but this is cool. One question, i have to do the pagination myself so when i add this filter i won’t get offset issues .. right?

  28. Mohsen

    Hi
    may I put your tutorials in my blog with a link to wpbeginner.com? my blog is in Farsi and I think many persian users need these tips.
    thanks a lot

    • Editorial Staff

      No you may not translate any of our tutorials entirely. You may write a summary and then link to our site.

      Admin

  29. Rilwis

    This hack excludes not only pages from search results, but also other custom post types. So if we have many custom post types in our WP site, we can put them in the statement like this:

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

    • Rein

      Thanks Rilwis, just what i needed!

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.