Block Google Search Indexing

Password Protect WordPress (PPWP) Pro will automatically block your password protected content, e.g. posts, pages, and custom post types from appearing in search results. The plugin achieves that by adding a noindex,follow meta tag to the header of these pages.

While this should suffice, it doesn’t guarantee that your protected posts and pages won’t appear in search engine results. In fact, different search engine crawlers may read these meta tags differently.

It’s also possible that the content was indexed before being protected by our plugin, and would still appear in search results. In that case, you should remove indexed pages and posts from Google search manually.

Please keep in mind that if you protect your whole site, all your content will be hidden from search engines whether they’re protected individually or not.

Modify robots meta tag

If you want your site to be indexed by Google and other search engines while being private to human, simply add the following code snippet to your (child) theme’s functions.php file.

add_filter('ppwp_sidewide_robots_content', 'ppwp_custom_robots_content');
add_filter('ppwp_single_page_robots_content', 'ppwp_custom_robots_content');
function ppwp_custom_robots_content()
{
    return "all";
}

In case you just need the home page to be indexed, use the following code snippet instead.

add_filter('ppwp_sidewide_robots_content', 'ppwp_custom_robots_content');
add_filter('ppwp_single_page_robots_content', 'ppwp_custom_robots_content');
function ppwp_custom_robots_content()
{
    if (is_front_page() || is_home()) {
        return "index,nofollow"; /*your-home-page-meta-tag*/
    }
    return "noindex,follow";/*other-pages-meta-tag*/
}

Related Features in our development backlog

  • Exclude protected content on the blog and archive pages, sitemaps, or recent posts widgets globally and individually
  • Block search indexing of protected category pages
  • Select different directives for the robots meta tag: none & noindex, follow
  • Remove noindex meta tag from unprotected pages/posts under sitewide protection
Lasted updated on March 12, 2021