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升級以後需要重新設置