WordPress Tutorials

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

When you are managing your WordPress website which offers WordPress search for something for your users, have you ever wanted to exclude some certain authors, pages or other more from it so as you can keep some certain posts, pages or others in private or optimize your site usability?

Normally, WordPress search can cover all pages, posts, authors on your WordPress site in search results. In the following post, we are to illustrate how to exclude specific posts, authors, categories, pages, and others from your WordPress search.

Why Should Your Exclude Specific Items From Your WordPress Search?

By default, after you performing WordPress search, then the search feature will show you’re the results from all your WordPress pages, custom post types as well as posts. The results are normally acceptable for majority of websites and it will not impact on your WordPress website performance and SEO.

However, for the webmasters running online shops, you must have some WordPress pages you won’t let them be in the WordPress search results, such as your “checkout” page, “thank you” page, “my account” page, and so on.

Also, if your WordPress is a membership site or you are running a LMS system, then there must be some pages or custom post types on the WordPress site which you want to or need exclude them from the search results.

In addition, there is a situation in which you may not want to hide a whole taxonomy or category, but others could want to hide posts from one or some specific authors. As a webmaster, you need that to optimize your website-search in the means of excluding some unnecessary content will give a better user experience for your audience or visitors, and also increase your site’s usability.

For the sake of better website SEO and performance, we will offer you easy ways to exclude those unnecessary items from your WordPress search.

1. Exclude Specific Pages, Posts, or Custom Post Types from WordPress Search

To fulfill this process, you need a helper named Search Exclude, which is a good WordPress plugin. Firstly, install the Search Exclude in WordPress. To know how to install a plugin in WordPress, you can visit here.

Then, activate the plugin. Upon activation, you just need to edit the page, customer post type or the post that you plan to exclude from the WordPress search results. When you editing it, the screen will show you a search exclude box.

Here is an option “Exclude from Search Results” and a checkbox next to it. You just need check it. After that, you need save your post/page.

Once it is done, that specific post or page will not show up in the WordPress search results anymore.

Now, you have done the task of excluding specific post, page or custom post type from search results. If you need view all the items just excluded from the results, you need visit “Settings” >> “Search Exclude” page, on which you can get a list of all the items you just excluded from your WordPress search results on your site.

The plugin Search Exclude also give you the ease of use about removing the restrictions you have made before: simply uncheck the checkbox next to those items you need add them back. Next, you need click on “Save Changes” to store your changes.

2. Exclude Specific Categories, Tags and Custom Taxonomy from the Search

The second method needs you to add short code snippets to your site. Don’t worry, it is still easy for beginners. If you never ever did this, you can search for the guides about how to add snippets in WordPress on the Internet. Let’s begin.

To exclude specific category from WordPress search, at first, you need find out the target category ID.

Then, you just add the short code as following to a website-specific plugin or your WordPress theme’s functions.php file.

Within above code, you have to use the target category ID to replace the value “7”.

At present, if you need exclude more categories, you just need to modify the short code like the following which will enable multiple categories exclusion.

In the short code above, we have already added the multiple category IDs which are all the target of this process to exclude, and use commas to make each category ID is added separately.

Exclude Specific Tags from the WordPress Search

Second, if you need exclude those posts which are filed under specific tags, then you can add the following short code.

Similarly, do not forget to use the tag ID to replace the value “19” in the code above, so as to exclude your target tags.

Also, just like excluding multiple categories, you can also exclude multiple tags by adding those tags’ IDs separated with commas.

Exclude Specific Terms in a Custom Taxonomy from the WordPress Search

Third, if you need exclude some certain terms in a custom taxonomy from the results, you will need add the code in below:

Again, you need remember to use that custom taxonomy to replace “genre” in the code and also replace “action” with the specific terms you need exclude. That’s done.

3. Exclude Specific Authors from the WordPress Search

Sometimes, with time going by, there will be some changes in authors or other reasons, and you need to exclude some posts written by specific authors from your WordPress search results. It is very possible. If that, you will have two methods to accomplish the task.

If the author or authors just has or have a few articles published, and you are sure that they won’t add any more articles on your site later, then you can simply follow the first method we talked above to exclude the author or authors’ posts from the search results.

Or, if the author or authors have too many posts, then you need change your method and use the code in below to achieve your goal of excluding the author or authors’ all posts from WordPress results.

As for the code above, you also need to change the value “24” into the user ID(s) of the author or authors you plan to exclude. You know the way to exclude more than one author, just like adding their user ID separated by commas.

That’s all. We have talked the easiest method of excluding specific posts, pages, custom post type, and authors from WordPress search. These methods are very easy for beginners, so we hope you can learn them and improve your WordPress user experience and website performance. You can check out our WordPress Tutorial to get more helpful guides.

One thought on “How to Exclude Specific Authors, Pages and More from Your WordPress Search”

  1. Running a website always needs to exclude something to update site content or improve site performance. So, thanks, the author. This guide is very useful.

Leave a Reply

Your email address will not be published. Required fields are marked *