显示带有永久链接的作者列表,并按评论计数排序


Display authors list with permalink and sort by comments count

我想创建一个页面,其中显示按评论计数排序的作者列表。我在网上只找到了这个:

显然也
function top_comment_authors($amount = 5) {
global $wpdb;
$results = $wpdb->get_results('
SELECT
COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
FROM '.$wpdb->comments.'
WHERE comment_author_email != "" AND comment_type = "" AND comment_approved = 1
GROUP BY comment_author_email
ORDER BY comments_count DESC, comment_author ASC
LIMIT '.$amount
);
$output = "<ul>";
foreach($results as $result) {
$output .= "<li><a href='".$result->comment_author_url."'>".$result->comment_author."</a></li>";
}
$output .= "</ul>";
echo $output;
}

然后在模板页中调用函数:

<?php top_comment_authors(); ?>

但是作者链接($result->comment_author_url)不能正常工作。该链接将我连接到我目前所在的同一页面。任何建议吗?

提前感谢

通常在wordpress中评论作者链接可以使用,

<?php echo get_comment_author_link( $comment_ID ); ?>