在虎头鱼那看到了通过修改wordpress文件的方法做到评论者主页链接新窗口打开,我嫌麻烦,于是放狗搜索了下,找到了个方法。
只需要把的下面的代码复制到主题的function.php中就可以了。
// Make comment author link URL open in new window
function comment_author_link_window() {
global $comment;
$url = get_comment_author_url();
$author = get_comment_author();
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
$return = "<a href='$url' rel='external nofollow' target='_blank'>$author</a>";
return $return;
}
add_filter('get_comment_author_link', 'comment_author_link_window');
如果非要用标准的external,那么我推荐这种方法,在header.php加入:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"> $(document).ready(function(){$("a[rel='external'],a[rel='external nofollow']").click(function(){window.open(this.href);return false})}) </script>
然后function.php加入:
// Make comment author link URL open in new window
function comment_author_link_window() {
global $comment;
$url = get_comment_author_url();
$author = get_comment_author();
if ( empty( $url ) || 'http://' == $url )
$return = $author;
else
$return = "<a href='$url' rel='external nofollow' rel='external'>$author</a>";
return $return;
}
add_filter('get_comment_author_link', 'comment_author_link_window');