查看: 69|回覆: 0

[教程] 去除wordpress中评论中的nofollow的方法

[複製鏈接]

2

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2010-11-25
發表於 2023-8-30 00:00:00 | 顯示全部樓層 |閲讀模式

我们先来看一下什么是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了。

回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部