WordPress GuideErrors → Search Results Showing Private Pages

Fixed: WordPress search results showing private pages

Seeing private pages show up in WordPress search results? That’s a problem—and one that needs fixing fast. Private pages should never be visible to logged-out users. If they are, there’s likely a settings error, a plugin issue, or a code-level conflict at play.

Let’s walk through exactly how to find the cause and fix it for good.

Make sure the page is actually private

Before you start troubleshooting your theme or plugins, it’s worth confirming the visibility setting itself.

Check visibility in the page editor

From your WordPress dashboard, go to PagesEdit the page in question. In the “Page” sidebar, find the Visibility setting under the “Status & Visibility” section. It should be set to Private—not Public or Password Protected.

A private page will display a message at the top of the editor like: “This is a private page. Only visible to site admins and editors.”

Test while logged out

Admins and editors can always see private pages while logged in. That means your tests might give you a false sense of visibility. Open an incognito/private browsing window or log out completely and try searching for the private page again.

Rule out theme or plugin conflicts

If the page is definitely private and still showing in search, your theme or a plugin might be overriding WordPress defaults.

Switch to a default theme

Go to Appearance → Themes, then activate a default WordPress theme like Twenty Twenty-Three. Run the same search again while logged out. If the problem disappears, your previous theme may be forcing private content to appear in queries.

Disable plugins one by one

From your dashboard, go to Plugins → Installed Plugins. Deactivate everything, then test your search. If the private page disappears, one of the plugins is the cause.

Reactivate each plugin one at a time and test the search after each one. Pay close attention to:

Clear all caches and check again

Sometimes the private page is already excluded, but cached content makes it look like it’s still there.

Clear your caching plugin

If you’re using a caching plugin, go to the plugin’s settings page and purge all caches.

Clear browser and server-level caches

Also clear your browser cache manually, or test in a private window. If your host uses server-level caching, clear those caches from your hosting dashboard or request support to do it.

Check for custom code in your theme

Custom functions in your theme—or even your child theme—might modify search queries to include content that should be hidden.

Search for pre_get_posts filters

Go to Appearance → Theme File Editor, open your functions.php file, and search for pre_get_posts. This filter allows developers to customize what WordPress includes in search results.

Look for any code that modifies queries like this:

function include_private_posts($query) {
  if ($query->is_search && !is_admin()) {
    $query->set(‘post_status’, array(‘publish’, ‘private’));
  }
}
add_action(‘pre_get_posts’, ‘include_private_posts’);

If you find something similar, comment it out or remove it. Then test the search again.

Remove or modify suspicious code

If you’re not sure what the code does, create a backup of your site, then remove the line and re-test. Or use a plugin like Code Snippets to safely disable custom functions temporarily.

Try search-specific plugins to exclude content

If you want more control over what shows up in search results, some plugins make it much easier than editing code.

Use Search Exclude

Search Exclude adds a checkbox to every page and post. Simply check “Exclude from search results” to hide it.

This works great for situations where you want public but low-importance pages (like thank-you pages or forms) hidden from search.

Add custom code to filter results (advanced)

For advanced users, you can hook into pre_get_posts yourself and explicitly prevent private pages from appearing in search:

function exclude_private_from_search($query) {
  if ($query->is_search && !is_admin()) {
    $query->set(‘post_status’, ‘publish’);
  }
}
add_action(‘pre_get_posts’, ‘exclude_private_from_search’);

This enforces the standard rule that only published content should appear in search results.

Verify the issue on a clean install

If you’re still stuck, try replicating the issue on a clean WordPress site. You can use a staging environment, a local setup with LocalWP, or a free sandbox tool.

If the private page doesn’t appear, the issue on your live site is likely due to a theme, plugin, or custom code. If it does, your WordPress environment may be misconfigured or corrupted.

Future-proof your site against visibility leaks

Once you’ve fixed the issue, take some steps to avoid it happening again—especially if you run a membership site or manage sensitive content.

Use a staging environment for tests

Never test visibility on your live site. Use a staging environment to activate plugins, switch themes, or adjust visibility rules without exposing private content.

Use content visibility plugins

Plugins like Block Visibility let you hide or show content blocks based on:

That’s a lot more control than the default “Private” toggle offers.

Audit visibility regularly

Make it a habit to check the visibility of key content—especially after major updates. Some SEO plugins or caching tools may unintentionally alter indexing rules, so spot-checking every few months is worth the effort.

Additional resources

Diagnosing WordPress errors on your site →

Even more common errors, how to troubleshoot them, and how to solve them

Fixed: WordPress failed to write file to disk →

Learn how to fix the “Upload: Failed to Write File to Disk” error in WordPress with easy troubleshooting steps.

What is managed WordPress hosting? →

What it means, what it includes, and how to decide if it’s right for you