Paul Underwood
PaulundSoftware Engineer

Display Top Commenters On Wordpress Blog

There are many blogs that like to reward the top commenters on their blog by displaying who they are on the sidebar. Another common approach is to display the most recent commenter. Here is a Wordpress snippet which you can use to display the top commenter for your blog. All you have to do is copy the following snippet into your functions.php page.

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
    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 = "<ul>";
foreach($results as $result) {
    $output .= "<li><a href='".$result->comment_author_url."'>".$result->comment_author."</a></li>";
$output .= "</ul>";
echo $output;

Using this function will output a list of commenters names with a link back to their website. To use this function all you will need to do is go to the place you want to display this list and call this function.

<?php top_comment_authors(); ?>

This will give you the most flexibility of adding this functionality, but there are also Wordpress plugins that will do this job for you. Here is a list of some of the best plugins you can download for free to display the top commenters. - Top Commentators Widget - Adds a sidebar widget to show the top commentators in your WP site. Adapted from Show Top Commentators plugin at Personal Financial Advice.

  • Simple Top Commenters - A sidebar widget that displays a list of top commenters across a site, showing the number of comments for each.
  • Top Commenters Gravatar - This WordPress plugin/widget will display top commenters of your blog in the form of gravatar images. The images can be stacked up or listed in a side
  • Top Contributors - Display your top commenters or authors in a widget.

Premium Wordpress Comment Plugins

Here are a couple of premium Wordpress plugins you can use to display comments on your Wordpress site. ### Advanced Comments Widget

Title Number of Comments, che total comment to display. Date Format, easy to customize date format, default jS, F Y h:i:s A. Comment Status, hold, approved, spam, trash. Order, ascending or descending. Orderby, comment_agent, comment_approved, comment_author, comment_author_email, comment_author_IP, comment_author_url, comment_content, comment_date, comment_date_gmt, comment_ID, comment_karma, comment_parent, comment_post_id, comment_type, user_id. Avatar Size, size in pixels. Empty Avatar URL :, the URL of image for empty avatar. Show Avatar, options to show or hide avatar. Show Date, options to show or hide date. Post Author, display comment by post author. Post Typedisplay comment based on post type Post Id, display comment based on post id. Comment Type, display comment or trackback. Searcht, search comment or post title for a keyword. Show Comment Content, options to display or hide comment content. Show Comment Count, options to display or hide comment count. Intro & Outro Text, if you want to add additional text or HTML . Custom Style & Script, if you want to add additional CSS style or javascript per given widget class. Advanced Comments Widget