How to Remove Pages from WordPress Search Results (Easy Guide)

How to Remove Pages from WordPress Search Results (Easy Guide)

How to Remove Pages from WordPress Search Results (Easy Guide)

Feb 11th, 2025

By, Editorial Team

WordPress

Why Remove Pages from WordPress Search Results?

Before diving into the “how,” let’s understand the “why.” Removing certain pages from your WordPress search results can significantly improve your site’s usability and user experience. Here are the top reasons:

Private or Restricted Content

Some pages on your site may contain private or restricted content meant only for specific users. For example:

  • Paid membership content
  • Admin-only pages
  • Drafts or unpublished posts

Excluding these pages ensures they don’t show up in public search results.

Avoid Irrelevant Pages

Certain pages like “Thank You,” “Privacy Policy,” or “404 Error” often appear in search results but aren’t helpful to visitors. Removing them keeps your search results clean and focused.

Better User Experience

When users search for something on your site, they expect quick and relevant results. Removing irrelevant or outdated pages helps them find what they’re looking for faster.

Cleaner Search Results

By excluding unnecessary pages, you ensure that your search results are neat, organized, and professional.

Step-by-Step Guide to Remove Pages from WordPress Search Results

There are two primary methods to remove pages from WordPress search results: using a plugin or modifying the functions.php file. Let’s explore both methods in detail.

Method 1: Using the Search Exclude Plugin

The Search Exclude plugin is a lightweight and easy-to-use tool that lets you hide specific posts or pages from your WordPress search results. Here’s how to use it:

Step 1: Install and Activate the Plugin

  1. Log in to your WordPress admin dashboard.
  2. Navigate to Plugins > Add New .
  3. In the search bar, type “Search Exclude” and press Enter.
  4. Locate the plugin and click Install Now .

After installation, click Activate .

  1. Open any post or page in the WordPress editor.
  2. On the right side of the editor, you’ll see a new checkbox titled “Search Exclude.”
  3. To hide the post or page from search results, simply check the box.

Click Update or Publish to save your changes.

Step 3: View Excluded Posts or Pages

  1. Go to Settings > Search Exclude in your WordPress dashboard.
  2. This page shows a list of all the posts and pages you’ve excluded, making it easy to track and manage.

Bonus Tips:

  • The plugin supports quick and bulk editing, so you can exclude multiple posts or pages at once.
  • Excluding pages from search won’t affect your SEO. These pages will still be inclhttps://assaptr.com/assaptr-services/white-label-services/white-label-seo-services/uded in your sitemap.

Method 2: Modifying the functions.php File

If you prefer not to use a plugin, you can exclude posts or pages from WordPress search results by adding custom code to your theme’s functions.php file. Here’s how to do it:

Step 1: Access the functions.php File

  1. Go to your WordPress admin dashboard.
  2. Navigate to Appearance > Theme File Editor .
  3. On the right side, under Theme Files , click on Theme Functions (functions.php) to open the file.

Note: Editing the functions.php file directly can be risky because updates to your theme may overwrite your changes. To avoid this, use a child theme if possible.

Step 2: Add Custom Code to Exclude Pages

Copy and paste the following code into the functions.php file:

if (!is_admin()) {

  function exclude_pages_from_search($query) {

    if ($query->is_search) {

      $query->set(‘post_type’, ‘post’); // Only show posts in search results

    }

    return $query;

  }

  add_filter(‘pre_get_posts’, ‘exclude_pages_from_search’);

}

This code ensures that only posts (and not pages) appear in your search results.

Step 3: Test Your Changes

  1. Go to your website’s front end and perform a search.
  2. Check if the excluded content (e.g., pages) no longer appears in the search results.

Optional Variation

If you want to exclude posts and show only pages, replace ‘post‘ with ‘page’ in the code above.

The Impact of Removing Pages from Search Results

Removing pages from your WordPress search results can have several effects on your site:

Effects on SEO and Analytics

  • Excluding pages won’t harm your SEO as long as those pages are still accessible via direct links or your sitemap.
  • However, if you exclude popular pages, you might notice a drop in traffic. Monitor your analytics to ensure this doesn’t happen.

Monitoring Performance After Changes

After making changes, keep an eye on your site’s statistics or analytics for a few weeks. This will help you understand the impact and make adjustments if needed.

FAQs on Removing Pages from WordPress Search Results

How do I hide pages in WordPress?

You can hide pages using plugins like Search Exclude or by password-protecting them. Alternatively, you can add custom code to your functions.php file.

How do I exclude pages from the menu in WordPress?

Go to Appearance > Menus in your dashboard. Uncheck the pages you want to exclude from the menu and save your changes.

How do I exclude a page from cache in WordPress?

If you’re using a caching plugin like WP Rocket or W3 Total Cache , go to the plugin’s settings and add the page URL to the exclusion list.

Conclusion

Removing pages from WordPress search results is a great way to improve your site’s user experience. Whether you’re hiding private content, paid material, or irrelevant pages, tools like the Search Exclude plugin or custom code in the functions.php file make the process quick and hassle-free.

By streamlining your search results, you help visitors find what they need faster while keeping unnecessary or restricted content out of sight. Just remember to monitor your site’s analytics after making changes to ensure everything works as intended.

With these easy steps, you can control your WordPress search functionality and create a cleaner, more efficient website for your users. If you need professional help with your site, our expert WordPress developers are here to assist you!

Don't Wait for Something to Break – Be Proactive!

WHAT'S YOUR TAKE?

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

We encompass a wide range of solutions, including eCommerce development, WordPress development, mobile app development, and digital marketing.

SUBSCRIBE NOW

Subscribe to AssaptR, our monthly look.
You have been successfully Subscribed! Oops! Something went wrong, please try again.

Contact info

Chat With Us
1
💭Need Help
Caught You! 👋🏻
Seeking For A Quick Assistance? We're Right Here!