WordPress评论默认打开评论作者的链接是当前窗口,这对别人访问不利,更改成新窗口打开的方法如下:
兼容测试:WP3.5通过
找到/wp-includes/comment-template.php,然后找到以下代码:
1 2 3 4 5 6 7 8 9 10 11 |
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 = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; return apply_filters('get_comment_author_link', $return); } |
把它修改成
1 2 3 4 5 6 7 8 9 10 11 |
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 = "<a href='$url' rel='external nofollow' class='url' target='_blank'>$author</a>"; return apply_filters('get_comment_author_link', $return); } |
也就是在
1 |
class='url' |
后面添加
1 |
target='_blank' |
注意:Wordpress升级以后需要重新设置