Show Top Comments or Commentators In WordPress Without A Plugin

Here is a simple code snippet to show the top commentators or comments in the wordpres without any plugin. The code are given blow.

function top_comment_authors($amount = 5){

global $wpdb;

$results = $wpdb->get_results(‘
COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
comment_author_email != “” AND comment_type = “” AND comment_approved = 1
comments_count DESC, comment_author ASC
LIMIT ‘.$amount


$output = “<ul>”;
foreach($results as $result){
$output .= “<li>”.$result->comment_author.”</li>”;
$output .= “</ul>”;

echo $output;


Paste the above script in the your functions.php file and use top_comment_authors() to show the list of commentators or comments. By default this function show the 5 list of commentators, you can change this value by passing the value in the function for example top_comment_authors(10).

Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.