how do you get the author’s username?

how do you get the author’s username?
I’m using this code
“get_the_author()”
I wanted to change this into author’s username, instead of author’s name.

Thankyou

5 Answers
5

In the Loop, it would be:

$authorname = get_the_author_meta('user_nicename');

Or:

$authorname = get_the_author_meta('displayname');

Or:

$authorname = get_the_author_meta('nickname');

Or any field that get_the_author_meta() accepts.

$authorname = get_the_author_meta('user_nicename',123);

If you just need to echo the name just use the_author_meta() instead:

the_author_meta('user_nicename',123);

Leave a Comment