WordPress.org

Ready to get started?Download WordPress

Codex

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.

Contents

Description

Returns nickname based on user ID.

Usage

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

Parameters

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

Return Values

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

Example

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

<?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;
}
?>