# How to display a list of authors in WordPress

URL: https://wp24x7.com/how-to-display-list-of-authors/
Updated: 2026-11-29
Type: blog post

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

## Key facts

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

> **Quick answer**
`wp_list_authors()` for a quick linked list, `get_users()` for custom markup, and a shortcode that returns its string for pages and widgets.

## What is the quickest way?

In a template file of your [child theme](/how-to-properly-set-up-child-theme), call:

```php
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()`:

```php
$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:

```php
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](/how-to-create-and-add-a-short-code-to-display-recent-posts) 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](/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:

```php
// 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:

```php
$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.

- **WordPress development** Author directories with filtering and profiles. [Read more](/wordpress-development)
- **Theme development** Layouts for your content. [Read more](/wordpress-theme-development)

**Need a custom author directory?**
Post a project and a person will scope it and quote in writing.
[Post a project](/post-project)
[Call the help desk](tel:+18043754450)

## Frequently asked questions

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

### Does wp_list_authors count custom post types?

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

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

### Why use has_published_posts?

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

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

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

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

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

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

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