I have a site which is displaying post tag in different format rather than the WP default tag format
WP default post tag url:
abc.com/tag/item
Where i have my tags in my website is like that
abc.com/post_tag/item
Tags in my site
It display post_tag instead of tag
So i don't see the noindex option for this custom post tag in the yoast or rank math to noindex them all,
Kindly help me to add piece of code in function.php to noindex all tag links of my site
https://readnational.com/post_tag/barbary-lion/ https://readnational.com/post_tag/cow/
So for all tags
I hope someone would help me thanks
CodePudding user response:
In robots.txt add:
User-agent: *
Disallow: /post_tag
Alternative in your functions.php:
function no_index_cpt()
{ $taxonomy = get_queried_object()->term_id;
if ($taxonomy === 'post-tag') {
print '<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">';
}
}
add_action('wp_head', 'no_index_cpt');