You can filter the comments in WordPress to display user with the most comments with count, email, author URL, etc.
Instructions: Add the following code to the functions.php file of your WordPress theme.
Use $result->comment_author_email
, $result->comments_count
, $result->comment_author_url
, to add additional parameters to this code.
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 = "<ul>"; foreach($results as $result) { $output .= "<li>".$result->comment_author."</li>"; } $output .= "</ul>"; echo $output; }
Simply use this code in your template files to show user with most comments.
<? top_comment_authors(); ?>
You may also enjoy enabling threaded comments in WordPress.
How can i only show the most commented user of a motnh? not all time only a month
exactly i was looking for this code. you have done it for me 🙂 thanks it was helpful for my newly theme.