I'm looking for a way to retrieve all authors with their avatar.
I know there is a way to get an authors avatar but I want to get all avatars of all the authors :)
echo get_avatar(get_the_author_meta('ID'), '160');
I tried to combine this command with wp_list_authors()
but didn't find a way.
How can I retrieve a list of all authors with their avatars?
Thank you!
I'm looking for a way to retrieve all authors with their avatar.
I know there is a way to get an authors avatar but I want to get all avatars of all the authors :)
echo get_avatar(get_the_author_meta('ID'), '160');
I tried to combine this command with wp_list_authors()
but didn't find a way.
How can I retrieve a list of all authors with their avatars?
Thank you!
Share Improve this question asked Oct 18, 2020 at 17:20 user196295user196295 3 |1 Answer
Reset to default 0I would loop through an array with the authors and then get their avatar and save them in a different array. You can use get_users()
to get the users and you already know how to get their avatar.
You can get users using get_users()
by giving it an array with arguments to specify what you need. You can see the available arguments to pass in the documentation for get_users(). This will return an array with users to loop through.
wp_list_authors
just uses the user API functions, and so can you,get_the_author_meta
is just a wrapper aroundget_user_meta( $post->post_author, 'ID'...
– Tom J Nowell ♦ Commented Oct 18, 2020 at 18:17wp_list_authors
is the solution, that function returns a HTML/plaintext string rather than an array of users – Tom J Nowell ♦ Commented Oct 18, 2020 at 21:45