0

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 1

    1

    I 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. this is the result of the tag cloud widget added in a sidebar

    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: This is the output of the tags from the get_the_tags function

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.