为什么WordPress去掉评论/留言里的链接这样做?因为非垃圾评论的垃圾评论一下子多了起来,有些人来评论就是为了推广网站链接,但很多都是与我们的网站毫无内容主题相关的。

WordPress去掉评论/留言里的链接

打开wp-includes/comment-template.php,找到这一段代码:


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);
}
//将代码
$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
//改为
$return = "$author";