How to display a list of authors in WordPress
List authors with wp_list_authors, build a custom author grid with get_users, add it as a shortcode, and avoid exposing login names.
At a glance
WordPress can print a list of its authors with one function. Use wp_list_authors for a quick list, and get_users when you want a custom layout with avatars or bios. This guide covers arguments, a custom author grid, a shortcode, filtering by role, pagination, privacy risks from usernames in URLs and common mistakes.
Updated November 29, 2026
- For WordPress developers building an author list or directory
- Quick list wp_list_authors()
- Custom layout get_users() or WP_User_Query
- Reuse a shortcode in a small plugin
- Privacy author URLs use user_nicename, which can expose login names
- Block themes no core block lists all authors
- Help WordPress development
On this page
WordPress can print a list of its authors with one function. Use `wp_list_authors()` for a quick list, and `get_users()` when you want a custom layout with avatars or bios.
What is the quickest way?
In a template file of your child theme, call:
wp_list_authors( array(
'show_fullname' => true,
'optioncount' => true,
'exclude_admin' => false,
'hide_empty' => true,
) );It prints a list of authors that links each name to their archive of posts. Useful arguments:
| Argument | Effect |
|---|---|
optioncount | Adds the number of posts after each name |
exclude_admin | Hides the account called admin when true, the default |
hide_empty | Hides authors with no published posts, also the default |
show_fullname | Shows the full name rather than the display name |
orderby and order | Sort by name or post count |
style | list by default; none for plain links separated by commas |
html | Whether the output is marked up as HTML |
echo | Set to false to return the string |
The function counts published posts of the standard post type only. Custom post types are not counted.
How do I build a custom author grid?
When you want avatars, short bios or your own markup, use get_users():
$authors = get_users( array(
'has_published_posts' => array( 'post' ),
'orderby' => 'display_name',
'order' => 'ASC',
) );
if ( $authors ) {
echo '<ul class="author-grid">';
foreach ( $authors as $author ) {
printf(
'<li><a href="%1$s">%2$s<span>%3$s</span></a></li>',
esc_url( get_author_posts_url( $author->ID ) ),
get_avatar( $author->ID, 96 ),
esc_html( $author->display_name )
);
}
echo '</ul>';
}has_published_posts limits the query to users who have published something, which avoids empty profiles. get_avatar() returns safe, already-escaped HTML, so do not escape it again. To show a bio, use get_the_author_meta( 'description', $author->ID ) wrapped in esc_html(), or wp_kses_post() if you allow formatting.
How do I make it a shortcode?
For use in pages and widgets, wrap the code in a shortcode that returns the string:
function mysite_authors_shortcode() {
$authors = get_users( array( 'has_published_posts' => array( 'post' ), 'orderby' => 'display_name' ) );
if ( ! $authors ) {
return '';
}
$out = '<ul class="author-grid">';
foreach ( $authors as $author ) {
$out .= sprintf(
'<li><a href="%s">%s</a></li>',
esc_url( get_author_posts_url( $author->ID ) ),
esc_html( $author->display_name )
);
}
return $out . '</ul>';
}
add_shortcode( 'author_list', 'mysite_authors_shortcode' );Use [author_list] in content. Our recent posts shortcode guide explains the pattern.
What about privacy and security?
Two points deserve a check:
- Usernames in URLs. An author's archive URL contains their
user_nicename, which WordPress sets from the username when the account is created. If your editors' login names appear in public URLs, an attacker has half of a login. Change the nicename and display name on those accounts to something different from the login name. Do this on a staging copy first, as changing it changes public URLs, and set up redirects if the old author pages were indexed. - Who should be listed. Do not list administrators, customers or members who have not agreed to be public.
has_published_postshelps, and so does listing by a specific role with therole__inargument.
For sites with many authors, limit the query with number and add pagination, since showing everyone slows the page.
What about block themes?
Block themes can show the post author inside the Query Loop with the Post Author block, but there is no core block that lists all authors. Build a shortcode or a custom block, or use a directory plugin. Check a plugin's update history and reviews before relying on it. For a custom author directory with filtering and profiles, see WordPress development.
How do I check it?
- Create
two test authors and publish a post for each.
- Confirm
the list shows both, and that a user with no posts is hidden.
- Click
a name and check the archive page loads.
- Check
the markup for correct escaping, using view source.
- Check
there are no login names in any URL.
How do I list only some authors?
Both functions can filter. With get_users() you can choose by role, by ID or by exclusion:
// Only editors and authors, leaving out one account by ID.
$authors = get_users( array(
'role__in' => array( 'editor', 'author' ),
'exclude' => array( 5 ),
'has_published_posts' => array( 'post' ),
'orderby' => 'display_name',
) );include takes an array of user IDs for a hand-picked list, such as a "meet the writers" page. With wp_list_authors(), use the include and exclude arguments with comma-separated IDs.
How do I paginate a long list?
Ask for a page of users at a time, and read the page number from the URL:
$per_page = 12;
$paged = max( 1, absint( get_query_var( 'paged' ) ) );
$query = new WP_User_Query( array(
'has_published_posts' => array( 'post' ),
'number' => $per_page,
'paged' => $paged,
'orderby' => 'display_name',
) );
$authors = $query->get_results();
$total = $query->get_total();Divide $total by $per_page to build page links. The paged argument is supported by WP_User_Query and the total is available because the query counts matches by default. For a shortcode used in a page rather than a template, get_query_var( 'paged' ) may be empty, so use a $_GET value you sanitise with absint() instead.
Common mistakes
| Mistake | Fix |
|---|---|
| Escaping twice | get_avatar() already returns safe HTML; wrapping it in esc_html() shows raw tags |
| Echoing from a shortcode | A shortcode must return its output |
| Code in a parent theme | A theme update overwrites it; use a child theme or small plugin |
| Listing everyone | Filter by role or has_published_posts |
| Forgetting the empty case | Return early when there are no authors |
Should this be a plugin or theme code?
If the author directory is part of your design, theme code is fine. If it should survive a theme change, as most directory features should, put it in a small plugin so switching themes does not remove it. The shortcode above works unchanged in a plugin file.
Author directories with filtering and profiles.
Read more02Theme developmentLayouts for your content.
Read morePost a project and a person will scope it and quote in writing.
How do I show avatars or bios in the list?
Use get_users with has_published_posts and loop over the results. get_avatar returns already-escaped HTML, so do not escape it again, and escape bios with esc_html or wp_kses_post.
Link to this answerWhy use has_published_posts?
It limits the query to users who have published something, which avoids empty profiles in the list.
Link to this answerHow do I add the list to a page or widget?
Wrap the code in a shortcode that returns its output, register it with add_shortcode and use [author_list] in content. A shortcode must return the string, not echo it.
Link to this answerShould this be theme code or a plugin?
If the directory should survive a theme change, put it in a small plugin. If it is part of your design, theme code in a child theme is fine. Avoid a parent theme, which updates overwrite.
Link to this answerKeep reading
Want an engineer on it?
Tell us what is wrong in plain words. A person reads it, today.