WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the following code in my function.php to display the top commenters in my theme:

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>".get_avatar($result->comment_author_email, 30).' <p>'.(($result->comment_author_url) ? "<a href='".$result->comment_author_url."'>" : "").$result->comment_author.(($result->comment_author_url) ? "</a>" : "")." (".$result->comments_count.")</p></li>";
$output .= "</ul>";

echo $output;


It works fine, but I'd like to exclude myself, aka the admin/author. Is this possible at all? If so, how would I do that? In what way would I have to modify the code above?

Thanks a lot in advance! :)

share|improve this question
up vote 2 down vote accepted

Extend the WHERE clause:

    comment_author_email != "" 
    AND comment_author_email != "YOUR_MAIL_ADDRESS" 
    AND comment_type = "" 
    AND comment_approved = 1
share|improve this answer
Perfect! Thank you so much! – japanworm Nov 20 '11 at 13:58

comment_author_email is fine but as far as I'm concerned I prefer using user id :

AND user_id!="1" 

It should do the job !

share|improve this answer
User ID 1 is not necessary an admin; it doesn't even have to exist. – toscho Apr 12 '13 at 11:18
you're right :/ – JMau Apr 19 '13 at 20:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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