0

Is there a way or a plugin so that I can see statistics for may comments and commenters? Like top commenters, most commented post, etc.

Thanks, Alex

1

For most commented posts you can use a custom loop in the sidebar for example:

<h3>Most Commented Posts</h3>

<?php $most_commented = new WP_Query('orderby=comment_count&posts_per_page=5');

if($most_commented->have_posts()) : ?>

<ul class="most-commented-posts">

<?php while($most_commented->have_posts()) : $most_commented->the_post(); ?>    

    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?> (<?php comments_number('0','1','%'); ?>)</a></li>

<?php endwhile; ?>

</ul><!-- most-commented-posts -->

<?php endif; wp_reset_query(); ?>

For the top commenters you can use something like this:

Top Commenters: exclude admin

And for comment stats like total comments, etc. use this function:

function comment_stats() {
    global $wpdb;

    // approved responses (comments and trackbacks) 
    $comment_stats['total_responses'] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");

    // trackback count
    $comment_stats['total_trackbacks'] = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_type = 'pingback' OR comment_type = 'trackback'");

    // comments count
    $comment_stats['total_comments'] = $comment_stats['total_responses'] - $comment_stats['total_trackbacks'];


   // Akismet spam captured
   if(function_exists('akismet_count')) {

              $comment_stats['spam_blocked'] = akismet_count();

  }

  if(!empty($comment_stats)) {

  $html .= "<ul class=\"comments-stats\">\n";

  foreach($comment_stats as $stat => $stat_value) :

       if(isset($stat_value) && $stat_value > 0) {

             $stat_name = str_replace("_", " ", $stat);

                           $html .= "<li>" .ucwords($stat_name). " : " .number_format($stat_value). "</li>\n";

       }

  endforeach;

  $html .= "</ul>\n";

  echo $html;

  }

}
0

I use Admin comments statistics plugin ( http://www.greatwpplugins.com/admin-comments-statistics/ ). I can see statistics for my post comments and users. Also I can see statistics for the blog admins, so I can see my activity on my blog. I recommend.

Regards,

Dora

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.