当前位置:首页 >  站长 >  建站经验 >  正文

沉缘seo:怎么去除wordpress中评论中的nofollow?

 2011-01-30 19:33  来源:   我来投稿 撤稿纠错

  【推荐】海外独服/站群服务器/高防

我们经常会遇到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了。

本文章有沉缘seo原创 A5首发 转载请保留作者和链接 谢谢!www.chenyuan66.com 欢迎共同探讨学习 QQ:32092216

申请创业报道,分享创业好点子。点击此处,共同探讨创业新机遇!

相关文章

信息推荐