function top_comment_authors($amount = 100) {
global $wpdb;
$prepared_statement = $wpdb->prepare(
'SELECT
COUNT(comment_author) AS comments_count, comment_author, comment_author_url, MAX( comment_date ) as last_commented_date
FROM '.$wpdb->comments.'
WHERE comment_author != "" AND comment_type = "" AND comment_approved = 1
GROUP BY comment_author
ORDER BY comments_count DESC, comment_author ASC
LIMIT %d',
$amount);
$results = $wpdb->get_results($prepared_statement);
$output = '';
foreach($results as $result) {
$output .= '
';
echo $output;
} ';
}
$output .= '
调用代码:
将代码添加到WordPress主题模板适当位置即可,其中的数字100可以控制显示数量。 版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!