# Authors List Shortcode

> Adds an [authors_list] shortcode that shows everyone who has published posts, with avatar, short bio and number of posts, linking to each author's archive, for "Our writers" pages.

- Type: PHP
- Runs: Run everywhere
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: shortcodes, authors, team
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/authors-list-shortcode/

## Code

```php
add_action( 'init', function () {
    add_shortcode( 'authors_list', function ( $atts ) {
        $atts = shortcode_atts( array( 'orderby' => 'post_count', 'bio' => 'yes', 'post_type' => 'post' ), $atts, 'authors_list' );

        $users = get_users( array(
            'has_published_posts' => array( sanitize_key( $atts['post_type'] ) ),
            'orderby'             => in_array( $atts['orderby'], array( 'post_count', 'display_name', 'registered' ), true ) ? $atts['orderby'] : 'post_count',
            'order'               => 'post_count' === $atts['orderby'] ? 'DESC' : 'ASC',
            'number'              => 50,
        ) );
        if ( ! $users ) {
            return '';
        }

        $counts = count_many_users_posts( wp_list_pluck( $users, 'ID' ), sanitize_key( $atts['post_type'] ), true );
        $html   = '<ul class="wpide-authors-list" style="list-style:none;padding:0;display:grid;gap:1.25rem">';
        foreach ( $users as $user ) {
            $bio   = 'yes' === $atts['bio'] ? get_the_author_meta( 'description', $user->ID ) : '';
            $html .= sprintf(
                '<li style="display:flex;gap:1rem;align-items:flex-start">%s<div><a href="%s"><strong>%s</strong></a> <small>(%s)</small>%s</div></li>',
                get_avatar( $user->ID, 64, '', '', array( 'extra_attr' => 'style="border-radius:50%;flex:none" loading="lazy"' ) ),
                esc_url( get_author_posts_url( $user->ID ) ),
                esc_html( $user->display_name ),
                esc_html( sprintf( _n( '%s post', '%s posts', (int) $counts[ $user->ID ] ), number_format_i18n( (int) $counts[ $user->ID ] ) ) ),
                $bio ? '<p style="margin:.3em 0 0">' . esc_html( wp_trim_words( $bio, 30 ) ) . '</p>' : ''
            );
        }
        return $html . '</ul>';
    } );
} );
```

## Notes

Example [authors_list orderby="post_count" bio="yes"]; users with no published posts are left out.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Authors List Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
