Combining wp_list_authors with get_user_meta

i am using the wp_list_authors function as the following:

?php wp_list_authors( array(
'show_fullname' = 'true',
'orderby'       = 'display_name',
'order'         = 'ASC'
)) ? 

However this shows the authors by firstname + lastname I want to switch that so it shows the users lastname + firstname.

I cant figure out how can i use the get_user_meta in the function.

It is possible or should I use something else than wp_list_authors?

Topic list-authors user-meta Wordpress

Category Web


What you want is not supported by wp_list_authors(). To output them the way you want you will need to use get_users() and display them yourself.

$authors = get_users(
    array(
        'orderby' => 'display_name',
        'order'   => 'ASC'
    )
);

foreach ( $authors as $author ) {
    echo esc_html( $author->last_name . ' ' . $author->first_name );
}

You can wrap the output in elements as needed, and pass $author->ID to get_user_meta() if you need any metadata. You can get a link to the author archive using get_author_posts_url().

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.