user meta – Combining wp_list_authors with get_user_meta

Question

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?

in progress 0
Simo Tamas 1 year 2021-09-13T05:41:35-05:00 0 Answer 0 views 0

Answer ( 1 )

    0
    2021-09-19T04:08:37-05:00

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

Leave an answer

Browse
Browse