admin管理员组文章数量:1122846
As we are noindexing all the Tag archives, this sometimes creates a lot of warnings in the Google GSC panel because the Google bot tries to follow the Tag hyperlinks and sees the noindex
meta tag, and then it generates hundreds of warnings in the category of Excluded by 'noindex' tag
since the Tag links are public on the posts.
I'm hoping to customize get_the_tags
to add rel="nofollow"
to every Tag archive hyperlink... and also for the Tag Cloud widget too if possible.
As we are noindexing all the Tag archives, this sometimes creates a lot of warnings in the Google GSC panel because the Google bot tries to follow the Tag hyperlinks and sees the noindex
meta tag, and then it generates hundreds of warnings in the category of Excluded by 'noindex' tag
since the Tag links are public on the posts.
I'm hoping to customize get_the_tags
to add rel="nofollow"
to every Tag archive hyperlink... and also for the Tag Cloud widget too if possible.
1 Answer
Reset to default 1I already had this challenge before and here is my personal solution for you:
1. For the tag cloud widget you can use this approach:
add_filter('wp_tag_cloud', 'add_nofollow_to_tag_cloud');
function add_nofollow_to_tag_cloud($content) {
// Add 'nofollow' to the links
$content = str_replace('<a href="', '<a rel="nofollow" href="', $content);
return $content;
}
I already tested this locally and it works fine.
2. For the get_the_tags() function you can add this function:
add_filter('term_links-post_tag', 'add_nofollow_to_tag_list');
function add_nofollow_to_tag_list($tag_list) {
$tag_list = str_replace('<a href="', '<a rel="nofollow" href="', $tag_list);
return $tag_list;
}
The outcome will be the same:
本文标签: seoHow to add 39nofollow39 flag to all Tag archive hyperlinks
版权声明:本文标题:seo - How to add 'nofollow' flag to all Tag archive hyperlinks? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300192a1930729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论