wordpress评论者网址链接在新窗口打开
在wordpress折腾的道路上,有很多人的文章给了我默默的帮助,虽然借用的是人家的折腾成果,但实践后居然我也会有很强烈的成就感。在此特别鸣谢万戈和荒野无灯长期以来给我这个小博客的默默帮助。
其实我早就对我的评论者链接打开方式不满了,每次我的访客可能直接跳出;不想跳出的访客还得后退回来,用户体验也很差。又受了小卢新文《巧妇难为无米之炊,假如有米呢》的刺激:
优点:由于卢松松对博客链接设置了blank标签,所以你点一个链接就可以在新窗口打开一个,极其方便,无需繁琐操作。
因此,立刻着手修改,方法非常之简单。
1、打开 wp-includes/comment-template.php
2、查找 function get_comment_author_link
3、在适当位置添加见下图:target=’_blank’ (引号是英文半角的,千万别写错呦)
1 function get_comment_author_link() {
2 /** @todo Only call these functions when they are needed. Include in if… else blocks */
3 $url = get_comment_author_url();
4 $author = get_comment_author();
5 if ( empty( $url ) || ‘http://’ == $url )
6 $return = $author;
7 else
8 $return = “<a href=’$url’ target=’_blank’ rel=’external nofollow’ class=’url’>$author</a>”;
9 return apply_filters(‘get_comment_author_link’, $return);
2 /** @todo Only call these functions when they are needed. Include in if… else blocks */
3 $url = get_comment_author_url();
4 $author = get_comment_author();
5 if ( empty( $url ) || ‘http://’ == $url )
6 $return = $author;
7 else
8 $return = “<a href=’$url’ target=’_blank’ rel=’external nofollow’ class=’url’>$author</a>”;
9 return apply_filters(‘get_comment_author_link’, $return);
» 转载请注明来源:宋夏博客 » 《wordpress评论者网址链接在新窗口打开》
80条评论
-
虽然我的目的是为了留下链接,但还是不得不顶你!
-
去试试。感谢哈!
-
新窗口中打开比较好
-
以前一直没去改,自己点着都觉着不方便……
还是改了的好…… -
前些日子正好思索这问题,回访其他网站后还得按返回唉
-
根据博主的文章去改了。哈哈、感谢分享哦
-
我现在改用jquery的方法来实现这个效果了,免去了修改WP文件的麻烦
-
按你说的做了,怎么不行呢…
-
这个需要学习下,多谢。而且合格很重要,可以留着部分人继续浏览
-
@Leyond,
我加了 不管用 WP3.0
-
关注一下。