苏苏网赚论坛

 找回密码
 立即注册
查看: 9337|回复: 0

wordpress评论中如何加nofollow标签

[复制链接]
跳转到指定楼层
楼主
发表于 2018-12-18 15:55:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
朋友问我wordpress留言版块的评论链接和昵称链接如何实现新窗口打开,还有给wp的评论链接加上nofollow。wordpress默认的是在本站打开,在WordPress评论中,会留下留言者的网址超链接,直接点击就会离开当前的页面,直接造成页面流量丢失,从而提高了网站的跳出率。让评论也像wp网站标题一样新窗口打开,这一点不仅仅对seo不利,而且也不符合用户体验。下面我们分别来说下wordpress评论链接新窗口打开和加nofollow。wordpress实现评论链接新窗口打开
代码见:
找到:WP-include/comment-template.php 这个文件
然后在:function get_comment_author_link( $comment_ID = 0 ) {
/** @todo Only call these functi** 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);
}
然后在找到:
$return = “$author”;
return apply_filters(‘get_comment_author_link’, $return);
}
加一个target=’_blank’
$return = “$author”;
return apply_filters(‘get_comment_author_link’, $return);
文字说明如下:
首页打开wp-includes文件夹,找到comment-template.php文件打开。找到以下代码:
    $return = “$author”;


在[url=]标签中插入一句[target="_blank"]尖括号中的内容,然后保存。这样,访客昵称所指向的链接就会在新窗口打开了。[/url]

当然,你也可以完全不让访客的昵称显示链接,就是将上面这行代码中$author前后的两个尖括号内的内容(a标签)直接删除。最后代码如下:
    $return = “$author”;


评论链接加nofollow
其实,笔者认为让访客昵称带上链接更有利于吸引人气。况且,我们都看到了nofollow这个属性,就是说即使搜索引擎见到这个链接也不会追踪过去,更不会传递权重或者PR。google和百度都支持nofollow属性。
在默认的WordPress模板中,我们看到评论人的留言链接网址都是设置成rel=’external nofollow’属性,如果你换的模板没有了的,你加上这个就行了,就这么简单,如http://shangban6.com。
热帖推荐
回复

使用道具 举报

广告合作|最大的网赚客中文交流社区!十年老站!

GMT+8, 2024-4-29 11:39 , Processed in 0.140400 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.1 VIP版

© 2012-2022 苏苏网赚论坛 版权所有 | 10年老品牌

快速回复 返回顶部 返回列表