Home » , , » How to display registered users comment count on your WP blog

How to display registered users comment count on your WP blog

You can show how many comments add by registered users on your blog. Try it.

1) Copy this code


<?php
global $wpdb;
$where = 'WHERE comment_approved = 1 AND user_id <> 0';
$comment_counts = (array) $wpdb->get_results("
SELECT user_id, COUNT( * ) AS total
FROM {$wpdb->comments}
{$where}
GROUP BY user_id
", object);
foreach ( $comment_counts as $count ) {
$user = get_userdata($count->user_id);
echo 'User ' . $user->display_name . ' comment count is ' . $count->total . '
';
}
?>
2) Paste it where you would like the count to be displayed on you wordpress blog.

you can re-arrange the code as desired.

Done.
If You Like product from here Click Here free product informationGoogle Android PC Tablet

0 comments:

Post a Comment

 
Support : Creating Website | SEO Template | Free Template
Copyright © 2011. Free Wordpress Theme And Templates For You - All Rights Reserved
Proudly powered by Blogger