Skip to content
Development

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.

By WP24×7 engineers5 min readPublished September 29, 2009Updated November 29, 2026

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

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:

ArgumentEffect
optioncountAdds the number of posts after each name
exclude_adminHides the account called admin when true, the default
hide_emptyHides authors with no published posts, also the default
show_fullnameShows the full name rather than the display name
orderby and orderSort by name or post count
stylelist by default; none for plain links separated by commas
htmlWhether the output is marked up as HTML
echoSet 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?

Author archives link to each writer without exposing login names

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_posts helps, and so does listing by a specific role with the role__in argument.

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?

  1. Create

    two test authors and publish a post for each.

  2. Confirm

    the list shows both, and that a user with no posts is hidden.

  3. Click

    a name and check the archive page loads.

  4. Check

    the markup for correct escaping, using view source.

  5. 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

MistakeFix
Escaping twiceget_avatar() already returns safe HTML; wrapping it in esc_html() shows raw tags
Echoing from a shortcodeA shortcode must return its output
Code in a parent themeA theme update overwrites it; use a child theme or small plugin
Listing everyoneFilter by role or has_published_posts
Forgetting the empty caseReturn 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.

Need a custom author directory?

Post a project and a person will scope it and quote in writing.

FAQ

Questions people ask

10 answers. Can't find yours? Ask an engineer.

What is the quickest way to list authors?

Call wp_list_authors in a child theme template with arguments such as show_fullname, optioncount, exclude_admin and hide_empty. It links each name to their post archive.

Link to this answer
Does wp_list_authors count custom post types?

No. It counts published posts of the standard post type only.

Link to this answer
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 answer
Why use has_published_posts?

It limits the query to users who have published something, which avoids empty profiles in the list.

Link to this answer
How 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 answer
How do I list only certain authors?

With get_users use role__in, include and exclude with user IDs. With wp_list_authors use include and exclude with comma-separated IDs.

Link to this answer
How do I paginate a long author list?

Use WP_User_Query with number and paged, read the page number from the query var and divide get_total by the per-page figure to build links. In a page shortcode, use a sanitised $_GET value with absint.

Link to this answer
Can author archive URLs expose usernames?

Yes. The archive URL contains user_nicename, which WordPress sets from the username at creation. Change the nicename and display name on public accounts, test on staging and redirect old author pages if indexed.

Link to this answer
Is there a core block that lists all authors?

No. Block themes can show the post author inside the Query Loop with the Post Author block, but listing all authors needs a shortcode, a custom block or a directory plugin.

Link to this answer
Should 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 answer

Keep reading

Want an engineer on it?

Tell us what is wrong in plain words. A person reads it, today.