how do you get the author’s username?

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