Index: wp-includes/author-template.php =================================================================== --- wp-includes/author-template.php (revision 6528) +++ wp-includes/author-template.php (working copy) @@ -442,66 +442,78 @@ $r = wp_parse_args( $args, $defaults ); extract($r, EXTR_SKIP); + $exclude_admin = $exclude_admin ? "WHERE user_login <> 'admin'" : ''; + $return = ''; - /** @todo Move select to get_authors(). */ - $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); + $authors = (array) $wpdb->get_results(" + SELECT $wpdb->users.ID, user_nicename, display_name, COUNT($wpdb->posts.ID) AS posts + FROM $wpdb->users " . (!$hide_empty ? 'LEFT' : '') . " JOIN $wpdb->posts + ON $wpdb->posts.post_author = $wpdb->users.ID AND post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " + $exclude_admin + GROUP BY post_author + ORDER BY display_name"); - $author_count = array(); - foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row) { - $author_count[$row->post_author] = $row->count; - } + if ( empty($authors) ) return false; - foreach ( (array) $authors as $author ) { - $author = get_userdata( $author->ID ); - $posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0; - $name = $author->display_name; + if ( $show_fullname ) { + $user_ids = $wpdb->get_col(null); - if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') ) - $name = "$author->first_name $author->last_name"; + $meta = (array) $wpdb->get_results(" + SELECT user_id, meta_key, meta_value + FROM $wpdb->usermeta + WHERE user_id IN (" . join(',', $user_ids) . ") AND (meta_key = 'first_name' OR meta_key = 'last_name') + ORDER BY meta_key, meta_value, user_id"); - if ( !($posts == 0 && $hide_empty) ) - $return .= '