Add rel="nofollow" attribute to WordPress tag

WordPress seventeen 3.7K Reading mode

WordPress tags have no rel="nofollow" attribute by default. The rel="nofollow" attribute is used to tell search engines that it is not necessary to track target pages, and spiders are prohibited from crawling and transferring weights. If you do not want search to include tags, you can add this attribute to the tag through the following code.

Add the following code to the current topic functions.php:

  1. function  cx_tags() {
  2.      $posttags  = get_the_tags();
  3.      if  ( $posttags ) {
  4.          foreach ( $posttags   as   $tag ) {
  5.              echo  '<a  class = "tag-link' . $tag->term_id . '"  href= "'.get_tag_link($tag).'"  rel= "nofollow" >'. $tag ->name.'</ a>';
  6.         }
  7.     }
  8. }

Use:

  1. <? php cx_tags();  ?>

Replace the label standard function in the theme template:

  1. <? php the_tags();  ?>

Of course, you can also rel= "nofollow" Add later target="_blank" Enables you to open a link in a new window or tab.

reference resources: http://codex.wordpress.org/Function_Reference/get_the_tags

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments seventeen    Visitors sixteen    Author one
    •  Moisten
      Moisten five

      Brother Bird, after setting the theme, why don't the home page display four recommended content?

      •  Tangshan website construction
        Tangshan website construction zero

        Thank you for answering my question just now. This article is very good and has been collected.

        •  By soy sauce
          By soy sauce two

          Brother Bird, I worship you and your theme very much. Please ask two questions. How come I don't have the four recommendations above the new theme? And whether I can migrate the video template of the previous theme to the new theme? Thank you very much.

          •  Host evaluation
            Host evaluation two

            In fact, I still don't agree with adding nofollow attribute to tags. Tags can play a very important role in search engine crawling for the whole site!

            •  All free
              All free one

              Learned

              •  Langfang website construction
                Langfang website construction one

                It looks very cruel

                •  Dragon slaying
                  Dragon slaying one

                  A very practical article.

                  •  People who can see the wind
                    People who can see the wind six

                    Brother Bird, the 4.0 version of WP has come out. Is there any incompatibility with the previous hotnews template?

                    •  Dream Flying Blog
                      Dream Flying Blog two

                      Very good

                      •  cut off all means of retreat
                        cut off all means of retreat zero

                        Passing by. Leave a message,

                        •  Miaojiang Bar
                          Miaojiang Bar three

                          X One tip.

                          •  Chen Ji's Blog
                            Chen Ji's Blog two

                            Hopes to launch the charging version as soon as possible, and hopes that the price can be more affordable.

                            •  European and American style picture bar
                              European and American style picture bar zero

                              Blogger, what if you want to add no follow to the links of the whole site?

                              •  At the end of gathering and dispersing
                                At the end of gathering and dispersing zero

                                How can nofollow add gadgets

                                •  Hi Bin
                                  Hi Bin one

                                  In fact, I just want to add nofollow_ (: з」∠)_

                                 anonymous

                                Comment

                                Anonymous netizens
                                 :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

                                Drag the slider to complete validation