Ticket #1659: bug1659.diff

File bug1659.diff, 1.2 KB (added by graeme, 7 years ago)
  • wp-includes/template-functions-author.php

     
    179179        $query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"; 
    180180        $authors = $wpdb->get_results($query); 
    181181 
     182        $query = "SELECT DISTINCT post_author AS author, 
     183                COUNT(ID) AS count 
     184                FROM $wpdb->posts 
     185                WHERE post_status = 'publish' 
     186                AND post_date_gmt <'".current_time('mysql','1')."' 
     187                GROUP BY post_author"; 
     188        $author_count = array(); 
     189        foreach ( $wpdb->get_results($query, ARRAY_A) as $row ) { 
     190                $author_count["{$row['author']}"] = $row['count']; 
     191        } 
     192 
    182193        foreach ( $authors as $author ) { 
    183194                $author = get_userdata( $author->ID ); 
    184                 $posts = get_usernumposts($author->ID); 
     195                $posts = isset($author_count["{$author->ID}"]) ? $author_count["{$author->ID}"] : "0"; 
    185196                $name = $author->nickname; 
    186197 
    187198                if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) 
     
    231242        } 
    232243} 
    233244 
    234 ?> 
    235  No newline at end of file 
     245?>