Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get author name

This function has been deprecated since Version 2.8. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use get_the_author_meta instead.


Returns nickname based on user ID.


<?php $author_name = get_author_name( $user_id ); ?>


(integer) (required) User ID.
Default: None

Return Values

Null if $user_id is not set or invalid. Returns a string with the user's nickname on success.


Below is an example showing how to display the author's name in archive.php

if( is_author() ){
    /* Store author ID from WordPress query in $user_id */
    $user_id = get_query_var( 'author' );
    /* Store nickname in $author_name */
    $author_name = get_author_name( $user_id );
    /* Only echo if $author_name is not null */
    if( $author_name !== null )
        echo 'Author Archive for ' . $author_name;