2

wp_list_authors() gives a list of author pages permalinks (site.com/author/john, site.com/author/jenny, etc). I want the same links using get_users() or get_userdata() functions instead. I need these functions because I display authors in a very customized way. However I don't know how to get proper author page slugs with those functions.

(for example, one author has an email address as her Username, and the wp_list_authors()-generated link for her author page has dashes in place of the "@" and the ".". This is to say that the author page slug is not necessarily the same thing as the username)

1

You can retrieve the author page URL for any user by their user ID using the WordPress native function get_author_posts_url(). Combining this with get_users() to retrieve an array of users, you can create an author list in pretty much any way you like!

Below is an example of the usage of get_author_posts_url(), displaying a link to the author page for the currently logged in user:

$userid = get_current_user_id();
echo '<a href="' . get_author_posts_url( $userid ) . '">' . __( 'User profile', 'my_textdomain' ) . '</a>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.