为WordPress标签添加rel=”nofollow”属性

WordPress标签默认并无rel=\”nofollow\”属性。rel=\”nofollow\”属性的作用是:告诉搜索引擎,无需追踪目标页,禁止蜘蛛爬行和传递权重。如果你不准备让搜索收录标签,可以通过下面的代码为标签添加该属性。

将下面的代码添加到当前主题functions.php中:

  1.  cx_tags() {
  2.      = get_the_tags();
  3.      () {
  4.         (  ) {
  5.              \'<a = href= rel=>\’.->name.\'</a>\’;
  6.         }
  7.     }
  8. }

用:

  1. <?php cx_tags(); ?>

替换主题模板中标签标准函数:

  1. <?php the_tags(); ?>

当然,你还可以在 rel=后面添加 target=\”_blank\” 实现在新窗口或标签中打开链接。

参考:http://codex.wordpress.org/Function_Reference/get_the_tags

    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容