去除wordpress中评论中的nofollow

我们经常会遇到nofollow属性,特别是wordpress的评论会自动添加上external nofollow属性。那么什么是nofollow呢?在我们不想要的时候怎么能去掉呢?

  我们先来看一下什么是nofollow。NoFollow是Google几年前提出的一个新标签,目的是减少垃圾留言。此标签表明链接与网站作者无关,也就是说搜索引擎不会用这个链接计算网站的 PR值。很多博客程序都会自动在评论链接中加上nofollow标签。现在主流的Blog程序,如WordPress和MovableType、z-blog等等,均默在其留言的链接中自动添加nofollow属性。在wordpress中加的是rel=” external nofollow”.例:Mitzie Farrer这段代码是沉缘seo在自己的小站源代码中找到的external nofollow 属性。

  那么nofollow与external nofollow有区别吗?在没明白二者的区别前我们先来了解一下二者的意思,rel=’external nofollow’与rel=’nofollow’其功能就中文译文”不要读取” 及”外部链接不要读取”的意思!由此可见二者的作用是相同的,只不过external nofollow是比nofollow更专业的写法,即明确指出链接为外部链接,蜘蛛可以略过。

  当我们不想让评论中的链接带有nofollow或者external nofollow属性时,该怎么去掉呢?

  那么请打开我们的wordpress,然后找到wp-include文件夹,打开comment-template.php页面,找到如下代码:

  function get_comment_author_link( $comment_ID = 0 ) {

  /** @todo Only call these functions when they are needed. Include in if… else blocks */

  $url = get_comment_author_url( $comment_ID );

  $author = get_comment_author( $comment_ID );

  if ( empty( $url ) || ‘http://’ == $url )

  $return = $author;

  else

  $return = “$author”;

  return apply_filters(‘get_comment_author_link’, $return);

  }

  在这些代码,去掉rel=’external nofollow’或者把这行代码换做target=’_blank’。这样我们的评论中就不会再出现external follow了。

此条目发表在 Wordpress 分类目录,贴了 , 标签。将固定链接加入收藏夹。

发表评论