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 Specific Pages, Authors, and More from WordPress Search

WordPress search includes everything by default, which isn’t always helpful.

For sites with large archives or eCommerce stores, this creates a messy user experience where people waste time scrolling through results that don’t matter to them.

From admin pages and author bios to out-of-stock products and old announcements, irrelevant search results can clutter the user experience on your site and drive users away.

The good news is, you can take complete control of what appears in your WordPress search results. And we’ve found a reliable method that works for any type of site.

In this guide, we’ll walk you through the easiest and most effective ways to exclude specific pages, authors, post types, and more from WordPress search. Let’s help your visitors quickly find the content they’re actually looking for. 🔍

How to exclude specific pages, authors, and more from WordPress search

Why Exclude Items From WordPress Search?

The default WordPress search shows results from all WordPress posts and pages, which works well for many websites.

However, sometimes, you may want to exclude certain pages and posts. For example, if you are running an online store, then you may want to remove the checkout and cart pages.

Similarly, if you manage a WordPress membership website or sell online courses, then you’ll typically want to exclude your premium, members-only content from public search results. You may even want to leave out other types of content, such as posts by specific authors.

That said, let’s take a look at how to easily exclude items from WordPress search. Here’s an overview of what we’ll show you how to do in this article:

💡 Note: In this guide, we will show you how to exclude content from your website’s search results. However, this content will still show up in the search engine results.

If you want to stop search engines from indexing a page, then check out our guide on how to hide a WordPress page from Google.

Install and Set Up the SearchWP WordPress Plugin

The easiest way to exclude pages, authors, categories, taxonomies, tags, and more is by using the SearchWP plugin. It’s the best WordPress search plugin used by over 30,000 sites.

It’s very beginner-friendly and makes it easy to improve the WordPress search feature to provide more helpful and relevant results. We explored its features in-depth when writing our detailed SearchWP review.

SearchWP

You can use this plugin to exclude entire content types from the search results. You can even exclude specific pages, posts, and custom post types.

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.

Enter SearchWP license key

Here, you need to enter your license in the ‘License Key’ box.

You can find this information in your account on the SearchWP site. Once you are done, make sure to click the ‘Verify Key’ button.

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 need to create a sitewide search engine before you can start excluding pages, posts, authors, and more from your custom search results page.

To get started, head over to SearchWP » Algorithm.

The SearchWP search optimization WordPress plugin

Here, you’ll see a section for the different content types that SearchWP searches by default, such as pages, posts, and media files.

Every section has its own ‘Applicable Attribute Relevance’ sliders that control how SearchWP will rank your site’s content.

For example, if you move the ‘Title’ slider to a bit to the left and the ‘Content’ slider to the right, then the content will carry more weight than the title.

An example of attributes with different relevancy settings in a custom search algorithm

At this point, you can exclude entire content types from the search results, such as all pages, posts, and custom post types.

For example, most WordPress blogs have a few pages, such as a contact form or homepage. You may want to exclude all pages from the search so that only blog posts show up in the search results.

To do this, simply click the ‘Sources & Settings’ button.

How to make more content searchable in WordPress

This opens a popup where you can uncheck the content that you want to exclude from WordPress search, including all pages.

Once you’ve done that, click on the ‘Done’ button.

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, authors, or other content, you’ll still need to save your new sitewide search algorithm first.

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

Saving your custom WordPress search algorithm

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

Now, the excluded content will never show up in the search results.

Exclude Specific Posts, Pages, and Custom Post Types from WordPress Search

Once you’ve created a custom search algorithm, you can exclude specific posts, pages, or custom post types from your WordPress search results.

For example, if you are using WooCommerce, then you might exclude your store’s contact form, account login, and checkout pages so that searches only ever return products. In this way, you can create a smarter WooCommerce product search and get more sales.

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.

The Exclude UI search addon

After that, open the post, page, or custom post type that you want to exclude from the WordPress search results.

If you are excluding a single post, then make sure the ‘Post’ option is selected in the right-hand menu, then check the ‘Exclude from search’ box.

Exclude single post from search

With that done, click on ‘Update’ to save your changes.

You can also exclude specific pages and custom post types following the same process described above.

The only difference is that the right-hand menu will say ‘Page’ or the name of the custom post type, instead of ‘Post.’

You can also exclude specific categories, tags, and other custom taxonomies from the WordPress search results.

For example, there might be some tags that authors use to organize and manage content in your multi-author WordPress blog. Since these tags are just for your team’s reference, you’ll want to exclude them from the search results.

To do this, simply go to SearchWP » Algorithm and then scroll to the ‘Posts’ section. Here, click on ‘Edit Rules.’

Editing the SearchWP search rules

This opens a popup where you can edit the search engine rules.

Simply click the ‘Add Rule’ button to create your first rule.

Click add rule button

Here, open the first dropdown menu and select ‘Exclude entries if.’

You can now use the rest of the settings to specify the content you want to exclude. For example, if you wanted to exclude a specific category, then you’d type in the category name.

You can also type in any custom taxonomies you want to exclude.

Excluding categories from the WordPress search results

To exclude specific post tags from the search results, simply open the dropdown menu and select ‘Tags.’

Then, type in the name of the tag you want to exclude.

Exclude specific tags

To add another rule, simply click the ‘Add Rule’ button and repeat the same process described above.

When you are happy with how the rules are set up, click ‘Done.’

Once you have finished customizing your rules, make sure you scroll to the top of the page and click on ‘Save’ to store your changes and rebuild the index.

How to save the SearchWP search engine

Now, when visitors search your WordPress website, SearchWP will exclude all the selected categories, tags, or custom taxonomies from its results.

If you’ve added multiple authors to your WordPress blog, then you may want to exclude specific authors from the search results. For example, you might exclude an author’s blogs if they’re no longer writing for your website.

You can exclude all the posts created by a specific author by adding code to your website. If you haven’t done this before, then see our beginner’s guide to pasting snippets from the web into WordPress.

Often, guides will ask you to add the custom code to your theme’s functions.php file. However, this isn’t very easy, and even a tiny spelling mistake or error in the code can cause common WordPress errors or even break your website completely.

Luckily, there is an easier way for users to add and manage custom code snippets.

WPCode is the best, most popular code snippet plugin used by over 1 million websites. It makes it easy to add code snippets without having to edit your functions.php file. You’ll also be able to update your WordPress theme without losing customizations.

Some of our partner brands use WPCode to add and manage their custom code snippets. We’ve also put it to the test, and you can find all about it in our full WPCode review.

WPCode's homepage

The first thing you need to do is install and activate WPCode. For more details, see our step-by-step guide on how to install a WordPress plugin.

💡 Note: For this tutorial, we’ll use the free WPCode version. That said, if you want to unlock the full code snippet library, enable code scheduling, and access code revision history, then you’ll need WPCode Pro.

Upon activation, head over to Code Snippets » Add Snippet. Here, hover over ‘Add Your Custom Code’ and select ‘Use snippet’ when it appears.

WPCode add custom code snippet

This will take you to the ‘Create Custom Snippet’ page, where you can type in a name for the code snippet.

This is just for your reference, so you can use anything you want.

Adding a title to a custom WordPress code snippet

Next, open the ‘Code Type’ dropdown and select ‘PHP.’

After that, you can go ahead and paste the following snippet into the code box:

<?php
function wpb_search_filter( $query ) {
  if ( $query->is_search && !is_admin() )
    $query->set( 'author','-24' );
  return $query;
}
add_filter( 'pre_get_posts', 'wpb_search_filter' ); ?>

You’ll need to replace 24 with the user ID of the author you want to exclude. If you need help finding the user ID, then see our guide on how to find IDs in WordPress.

You can also exclude multiple authors from the search results by adding their user IDs separated by a comma:

<?php
function wpb_search_filter( $query ) {
  if ( $query->is_search && !is_admin() )
    $query->set( 'author','-24, -12, -19' );
  return $query;
}
add_filter( 'pre_get_posts', 'wpb_search_filter' ); ?>

Below the code box, you will see insertion options. There are two main insertion options: ‘Auto Insert’ and ‘Shortcode.’

You’ll want to choose the ‘Auto Insert’ method so that WPCode automatically inserts and executes the code across your entire site.

Auto inserting a custom WordPress code snippet

You can also assign tags to the code snippet. This can help sort your code snippets by topic and functionality.

When you are happy with how the snippet is set up, scroll to the top of the screen and click on ‘Save Snippet.’

Saving a WPCode WordPress code snippet

Finally, you can make the code snippet live on your site by clicking the ‘Active’ toggle.

Don’t forget to save this change by clicking on ‘Update.’

Activating a custom code snippet in WordPress

Now, the author will be excluded from the WordPress search results.

Bonus: Adjust WordPress Search Results to Promote Key Content

Want to guide users toward your most valuable content, like product pages, lead magnets, or cornerstone articles?

With the SearchWP plugin, you can customize the order of search results to highlight specific posts or pages.

To do this, you’ll need the Custom Results Order extension. You can install it from SearchWP » Extensions.

Custom Results Order extension for SearchWP

Then, you can identify the keywords your visitors are searching for most often.

You can see the data in the ‘Statistics’ section.

SearchWP statistics

Next, go to the ‘Algorithm’ page and open the ‘Custom Results Order’ tab.

Enter a keyword, then select the post or page you want to promote and click ‘Promote to Top.’ This ensures your important content shows up first when users search for related terms.

Promote to top

You can update or fine-tune this list anytime, making it easy to align your search results with your marketing goals or seasonal campaigns.

For details, you can check out our guide on how to customize the search results page in WordPress.

There, you can also find more tips to improve your site’s search, including adding live search, enabling search in shortcode outputs, making PDFs and documents searchable, and more!

FAQs About WordPress Search

Now that you’ve excluded certain pages or content types from WordPress search, you might still have a few questions about how it all works. Let’s go over some of the most common ones to help you fine-tune your setup:

Why should I exclude certain pages or posts from my WordPress search?

Keeping search results clean and relevant improves the user experience. For example, you probably don’t want visitors landing on admin, thank-you, or checkout pages when they use your site’s search.

Can I exclude content without using a plugin?

Yes, you can add some code to your theme’s functions.php file to do this manually. But if you’d rather skip the technical steps, a WordPress search plugin makes the process much easier and safer, especially if you’re not comfortable editing code.

How do I find the user ID for excluding a specific author?

Just head to your WordPress dashboard and go to ‘Users.’ Hover over the author’s name, and you’ll see their user ID appear in the status bar of your browser (usually in the bottom left corner).

Finding User ID by hovering over the user's name

What happens if I need to exclude multiple categories or authors?

No problem. You can list multiple IDs, separated by commas, whether you’re using plugin settings or adding custom code. It’s a quick way to exclude several items at once.

Will excluding content from WordPress search also remove it from Google search results?

Nope! Hiding something from your site’s internal search doesn’t affect how it appears on Google. If you want to keep content or pages out of search engines, you’ll need to use an SEO plugin like All in One SEO or Yoast SEO to control indexing settings.

We hope this article helped you learn how to exclude specific pages, custom post types, authors, and more from WordPress search. Next, you may also want to see our guides:

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.

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

17 CommentsLeave a Reply

  1. Thanks for the WP Code snippet. I also have articles on my blog that are hosted and I don’t want them to be searchable. Since I also have the author of the text registered with them, I can conveniently exclude them from the search thanks to your snippet. Thank you very much.

  2. Hi!

    I have a doubt, it’s possible to exclude a word from search?

    For example:
    – Keyword to search: laptop
    – Not search with the word: macbook

    The results should be all the laptops but no the ones who contains the word “macbook”

    Thanks and regards!

    • That kind of customization would require editing how your search engine works, it would be better to use tags or categories for separating your content like that normally.

      Admin

  3. Hi,

    Will this affect SEO in any way?

    I want a specific post to be excluded from my own sites Searchbar, but still want it to be found by Google SERP’s.

    Thanks,

    • It will make your page more difficult to find and we have not tested but it shouldn’t have a major effect as long as the page can be easily found.

      Admin

  4. Hi,
    The code in “Exclude Specific Tags from WordPress Search” section is faulty and causes WP to throw an error.

      • Please look at the snippet once again. (I am only talking about the part after the heading which says “Exclude Specific Tags from WordPress Search”) First of all the syntax is wrong. on line 4 you have } but you have never started a block with {.
        Second, You have :
        add_filter( ‘pre_get_posts’, ‘wpb_search_filter’ );
        but never defined a function named : wpb_search_filter

        basically the code is missing one line at the type which should be :

        function wpb_search_filter( $query ) {

        So either it’s expected from the users to complete the code from what you added in the upper parts of this article or this snippet of code is not complete.

        • Thank you for clarifying that, it looks like our code block had a hiccup and we resolved the issue so the code should show correctly now. :)

  5. Hi there!

    By checking this “search exclude” will the post still be indexed and accessible via google?

    I’m trying to find the best way to have a post type available to those who have a link to it. However I do not want people to be able to access it via google or have to password protect the posts. Any suggestions for the best way to do that? (I can explain further if needed)

    Any help appreciated! Thanks :)

  6. Thank you so much for this post! I was having trouble not just with getting Google to stop indexing my Thank You page, but also preventing my own site from indexing it in the search as well! This solved both of my problems.

  7. I have installed the plugin, checked the exclude check on one page but I continue to see on search result, why?

    • There are a few possible reasons. If you reach out to the plugin’s support they should be able to help you solve the issue :)

      Admin

  8. Thanks for the VERY helpful post. As I am not a “coder,” I do have one question…

    How do I exclude **more than one** specific terms in a custom taxonomy? How will the code change?

  9. Once I’ve excluded a certain page from a WP Search, do I have to change the setting from ‘Public’ to ‘Private’?
    I want to be able to give only certain people access to a certain page (for free information or paid information)- but they’re not editors on my blog.

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.