Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Exclude Specific Pages, Authors, and More from WordPress Search

Do you want to exclude specific pages, posts, authors, and more from WordPress search?

By default, WordPress search includes all posts and pages in the search results.

In this article, we’ll show you how to easily exclude specific pages, posts, authors, categories, and more from your WordPress search results.

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, pages, and custom post types. This is acceptable for most websites and does not affect WordPress SEO or performance.

However, if you’re running an online store, then there are some pages you may not want to appear in the search results. For example, the checkout page, my account page, or a thank you page.

Similarly, if you’re running a WordPress membership website, or selling online courses, then there are pages and custom post types you may want to exclude from the search results.

Some WordPress website owners may want to hide a category or taxonomy, while others may want to hide posts from specific authors. Optimizing your website search by excluding unnecessary items offers a better user experience and improves your website’s usability.

That being said, let’s take a look at how to easily exclude items from WordPress search.

Install and Setup 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.

SearchWP

It’s very beginner friendly and lets you improve your WordPress search to provide more relevant results.

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, navigate Settings » SearchWP and then click the ‘License’ menu option.

Enter SearchWP license

Then, you need to enter your license key into the ‘License’ box and click the ‘Activate’ button. This information is available in your account on the SearchWP website.

Next, click on the ‘Engines’ menu to set up your new WordPress search engine.

SearchWP default engine

This brings you to a page where you need to configure your initial search engine settings. It’s similar to creating a Google search algorithm that’s only for your WordPress blog.

You need to create a sitewide search engine before you can start excluding pages, posts, authors, and more from search.

You can change the search engine settings by clicking on the ‘Posts’, ‘Pages’, and other custom post type drop downs.

Every section has its own weight multiplier that changes how the search engine will rank your website’s content.

For example, if you move the ‘Content’ slider all the way down, then the title, post slug, and excerpt will hold more value.

SearchWP algorithm sliders

At this point, you can also completely exclude pages, posts, and custom post types from appearing in search. This can be useful if you have a testimonials custom post type or other content types you don’t want showing up in search.

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

Click sources and settings

This brings up a popup where you can uncheck ‘Posts’, ‘Pages’, and custom post types you’ve created.

Then, click the ‘Done’ button to exclude the pages, posts, or custom post types you selected from appearing in search.

Exclude all pages, posts, or custom post types

After you’re done customizing the default search engine settings, you need to click the ‘Save Engines’ button to create your first search engine.

Now, when your visitors do a search on your website they’ll see improved results.

Save search engine

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

To exclude specific posts, pages, and custom post types from the WordPress search results, we’ll be using the Exclude UI extension from SearchWP.

When logged into your SearchWP account, go to the Exclude UI download page and click the ‘Download Extension’ button.

Download exclude UI extension

Then, install and activate the extension the same way you installed the SearchWP plugin above.

Next, open up the post, page, or custom post type you want to exclude from the search results.

If you’re 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

Make sure to click ‘Update’ to save your changes.

When excluding pages and custom post types from WordPress search, the steps will be the same as above. The only difference is the right hand menu will say ‘Page’, or the ‘Name’ of the custom post type, instead of ‘Post’.

Exclude Specific Categories, Tags, and Custom Taxonomies From WordPress Search

If you want to exclude specific categories, tags, and other custom taxonomies from the WordPress search results, then you can do this by adding rules to your search algorithm.

Simply go to Settings » SearchWP and then click the ‘Edit Rules’ button in the ‘Posts’ section.

Click edit rules

This brings up 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

To exclude a specific category, select ‘Exclude entries if:’ drop down option, and then type your category name into the empty box. You can also type in custom taxonomies to exclude them as well.

Then, click the ‘Done’ button.

Exclude specific category

To exclude specific post tags from search, simply select the ‘Tags’ drop down option.

Then, enter the name of your tag in the empty box, and click ‘Done’.

Exclude specific tags

To add multiple rules at once simply click the ‘Add Rule’ button again.

Once you’re finished customizing your rules, make sure you click the ‘Save Engines’ button to update your search engine.

Now, when visitors use your search engine, the categories, tags, or custom taxonomies you set will be hidden from the results.

Exclude Specific Author Posts From WordPress Search

If you want to exclude posts created by a specific author from WordPress search results, then there are two ways to do that.

If the author only has a few posts, and they won’t be publishing any more, then you can exclude their individual posts from WordPress search.

However, if there are a lot of posts written by the author, then you need to add code to WordPress to exclude them all at once. If you haven’t done this before, then see our beginner’s guide to pasting snippets from the web into WordPress.

Next, you can add the following code to your theme’s functions.php file, in a site-specific plugin, or by using a code snippets plugin.

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' );

Don’t forget 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 use the same code to exclude multiple authors by adding their user IDs separated by a comma.

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' );

We hope this article helped you learn how to exclude specific pages, custom post types, authors, and more from WordPress search. You may also want to see our guide on how to choose the best blogging platform and our expert picks of the best virtual business phone number apps.

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.

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

16 CommentsLeave a Reply

  1. 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

  2. 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

  3. 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. :)

  4. 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 :)

  5. 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.

  6. 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

  7. 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?

  8. 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.