非常感谢。发现此问题的任何其他人的最终(工作)代码:
function top_comment_authors($amount = 200) {
global $wpdb;
$prepared_statement = $wpdb->prepare(
\'SELECT
COUNT(comment_author) AS comments_count, comment_author, 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 = \'<div class="comments">\';
foreach($results as $result) {
$output .= \'<p class="comment-author">\'.$result->comment_author.\' • \'.$result->comments_count.\' comments, last comment \'.human_time_diff(strtotime($result->last_commented_date)).\' ago</p>\';
}
$output .= \'</div>\';
echo $output;
}