As a thank you to the hundreds of people who have contributed to my blog through comments, I have created a page which (1) lists them, with (2) how many comments they have made. So far, so good! What would be a great final touch however would be to show (3) how many days since they last posted, and that's where it's gone past my abilities. Any good ideas?
Here's what I've got for the working part:
function top_comment_authors($amount = 250) {
global $wpdb;
$results = $wpdb->get_results('
SELECT
COUNT(comment_author) AS comments_count, comment_author
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 '.$amount
);
$output = '<div>';
foreach($results as $result) {
$output .= '<p>'.$result->comment_author.' ('.$result->comments_count.' comments)</p>';
}
$output .= '</div>';
echo $output;
}