Support » Fixing WordPress » How to Exclude admin from the commenters list

  • Moderator t-p


    I use this hack to display 5 top commrnters. I works great.

    The code also display admin in the list.

    Can someone please guide me how to exclude admin from the list. Thnks.

    The code is:

    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
            GROUP BY
            ORDER BY
                comments_count DESC, comment_author ASC
            LIMIT '.$amount
    $output = "<ul>";
        foreach($results as $result){
            $output .= "<li>".(($result->comment_author_url) ? "<a href='".$result->comment_author_url."'>" : "").$result->comment_author.(($result->comment_author_url) ? "</a>" : "")." (".$result->comments_count.")</li>";  
        $output .= "</ul>";
        echo $output;

    You may have better hack that also excludes the admin, please share. thanks.

  • The topic ‘How to Exclude admin from the commenters list’ is closed to new replies.