wp_list_authors() as an array
If you need to display all the authors of your site and you want to format the way the list is returned, you might as well forget wplistauthors. Instead, add this to your theme's functions.php file and enjoy looping thru your authors and formatting the list to your liking.
function get_all_authors() {
global $wpdb;
foreach ( $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 = get_userdata( $row->post_author );
$authors[$row->post_author]['name'] = $author->display_name;
$authors[$row->post_author]['post_count'] = $row->count;
$authors[$row->post_author]['posts_url'] = get_author_posts_url( $author->ID, $author->user_nicename );
endforeach;
return $authors;
}
Written by Dwight Scott
Related protips
2 Responses
This is great - thanks very much!
over 1 year ago
·
@lexnels No problem!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#