De-Index Member profiles and Unit pages from Google

Sometimes Google indexes the Member profiles or Unit pages and it is not easy to log into Google webmasters and mark every url  for de-indexing. Even the Robots.txt does not guarantee removal . [ reference : https://www.contentkingapp.com/academy/robotstxt/faq/prevent-indexing/ ]

We need to add a meta tag for removal of these pages from Google.

Simply add below code :

For Units :
p.s : It might not be a good idea to de-index units from Google as they add more search results to your site and since the units are under a login lock, users landing on those pages can not access it.
 

add_action('wp_head',function(){
if(is_singular('unit')){
echo '<meta name="robots" content="noindex">';
}
});

For Member profiles :

add_action('wp_head',function(){
if(function_exists('bp_is_user') && bp_is_user()){
echo '<meta name="robots" content="noindex">';
}
});

Leave a Reply

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