Last active
December 31, 2015 05:39
-
-
Save shemul49rmc/7942077 to your computer and use it in GitHub Desktop.
Show Top Commenters On WordPress Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show Top Commenters On WordPress Blog By http://goo.gl/ht6fZo | |
*/ | |
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 = " | |
"; foreach($results as $result) { $output .= " | |
".$result->comment_author." | |
"; } $output .= " | |
"; echo $output; } | |
Now Add the below code anywhere you want to show the top commenters list. | |
<?php top_comment_authors(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment