Knowing how to customize default WordPress search is key for many site owners. In fact, according to BuiltWith statistics, over 43% of the top 1 million websites run on WordPress.
With WordPress powering over 400 million sites, that‘s a lot of built-in search functionality to optimize.
By default, WordPress search returns results from across all published posts, pages, products, etc. However, site owners often want to selectively exclude certain content like checkout pages, premium posts, specific authors, and more from search results in order to improve relevancy for visitors.
For example, an ecommerce store owner may want site search to only display products – not account dashboard pages.
This guide will teach you how to easily customize default WordPress search with recommended plugins and code snippets to:
- Exclude entire post types like pages
- Remove individual posts, pages, and custom post types
- Eliminate specific tags, categories, authors, and custom taxonomies
Read on to learn everything you need to know about precisely controlling WordPress search results in 2023.
Why Exclude Content From WordPress Search Results?
Before diving into the how-to specifics on excluding WordPress content from search, let‘s explore some of the top reasons site owners customize default search functionality:
Improve Online Store Product Search Relevancy
According to BrightEdge research, over 51% of online searches are product-related queries.
So if you run an ecommerce site, excluding irrelevant pages from search like cart, checkout, billing pages can help site visitors better find relevant products.
Hide Private Members-Only Content
For site owners running membership sites or selling premium content, removing gated posts from public search results can prevent confusion and improve conversion rates.
Reduce Low-Value Search Results
Generic pages like "Contact Us", "About", or "Home" that offer little value to searchers can be excluded to simplify search and reduce result count.
Eliminate Ex-Author Content
If you have a blog with multiple authors and some writers are no longer contributing content, removing their outdated posts from search helps improve relevancy.
Now that you know why excluding content from WordPress search is so useful, let‘s explore your options…
How To Exclude Specific Pages, Posts, Authors, and More From Search
There are two recommended methods we‘ll cover to customize default WordPress search on your site and selectively exclude content:
Using a dedicated WordPress search plugin (simplest method)
Writing PHP code snippets (for advanced users)
Let‘s compare some pros and cons of each approach:
WordPress Search Plugins vs Code Snippets
Feature | Search Plugin | Code Snippet |
---|---|---|
Skill Level Required | Beginner | Advanced |
Setup Difficulty | Easy | Complex |
Maintenance/Future Updates | Automatic | Manual |
Customization Options | Dynamic rules based exclusions | Limited specifics in code |
Potential Site Issues | Minimal | Higher risk of conflicts |
For most users, a dedicated WordPress search customization plugin is the fastest, easiest way to achieve precise search result exclusions. But developers may prefer writing their own PHP code snippets for maximum control.
Next, let‘s explore both options in more detail…
Method #1: Use a WordPress Search Plugin (Easiest Approach)
If you want a user-friendly way to customize default WordPress search, a dedicated plugin is best. Our recommendation is the popular SearchWP plugin used by over 40,000 WordPress sites.
Here are the key benefits of improving WordPress search with SearchWP:
✅ User-friendly customization options for all skill levels
✅ Dynamic rules to target exclusions (no coding)
✅ Fine-tune rankings based on relevance
✅ Detailed usage stats available
✅ Actively maintained and updated
Let‘s look at how to install SearchWP and leverage it to precisely exclude pages, posts, authors, tags, categories, and any other content from WordPress search results.
Step 1: Install & Activate SearchWP Plugin
First, install and activate the SearchWP plugin like any standard WordPress plugin.
You can find details in our guide on how to install a WordPress plugin if you need help with this initial step.
Step 2: Create a Custom Search Algorithm
Next, navigate to SearchWP » Algorithm and you‘ll find options to fine-tune the default search functionality:
Key settings:
✅ Attribute sliders – Control how titles, content, etc. impact rankings
✅ Sources – Check/uncheck boxes to include/exclude entire post types
✅ Add Rules – Set dynamic rules to exclude content based on categories, tags, post IDs, authors, custom taxonomies, etc.
This allows you to essentially create a custom search engine algorithm tailored to your site.
For example, if running an online store, you may exclude all static pages, custom post types like forums, specific product categories, and tags from search results leaving only relevant products.
Step 3: Exclude Specific Pages and Posts
In addition to controlling search results at a global post type or taxonomy level, you can also precisely exclude individual pieces of content.
Install the SearchWP Exclude UI extension.
Then when editing any post or page, you‘ll find an "Exclude from search" checkbox. Simply check it to remove that singular page, post, or custom post type from search index and results.
This granular exclusion control paired with global search algorithm rules provides the flexibility to craft custom-tailored WordPress search results catered to your visitors.
Step 4: Save Algorithm and Rebuild Index
With your exclusions configured, save your custom algorithm and SearchWP will rebuild its index applying all new settings and rules site-wide automatically.
So using the SearchWP plugin, you can easily achieve precise search results filtering without technical expertise.
Method #2: Exclude Authors via Code Snippets (Advanced)
While we recommend SearchWP for most users, developers can take a more hands-on approach by inserting PHP code snippets to handle excluding authors from WordPress search results.
This example would exclude posts from authors with IDs 56, 82, and 34:
function wpb_search_filter( $query ) {
if ( $query->is_search && !is_admin() )
$query->set( ‘author‘,‘-56, -82, -34‘ );
return $query;
}
add_filter( ‘pre_get_posts‘, ‘wpb_search_filter‘ );
To implement, we recommend adding snippets safely with a plugin like WPCode rather than editing PHP files directly.
This code solution may provide more flexibility for developers. But generally, we suggest SearchWP as the easiest method for most WordPress site owners to achieve customized search result exclusions.
Summary: Excluding WordPress Pages, Authors, and More from Search
In closing, strategically excluding certain content from your WordPress powered site‘s default search results can dramatically improve relevancy and experience for visitors.
Checkout, account, outdated author content, and other pages can clutter results. By following this guide, you‘re equipped to easily leverage SearchWP or custom code snippets to display only the most relevant content to searchers.
So give one of these methods a try and let me know if you have any other questions on customizing WordPress search!