Using WordPress ‘is_author()’ PHP function

The is_author() WordPress PHP function determines whether the query is for an existing author archive page.

Usage

is_author( $author )

Custom example:
Input: is_author('john-smith')
Output: true (if the author archive page for ‘john-smith’ is being displayed)

Parameters

  • $author (int|string|int[]|string[]) – Optional. User ID, nickname, nicename, or an array of such to check against. Default: ''

More information

See WordPress Developer Resources: is_author()

This function was introduced in Version 1.5.

Examples

Check if any author page is being displayed

if ( is_author() ) {
  echo "This is an author archive page.";
}

Check if the archive page for author ID 4 is being displayed

if ( is_author( 4 ) ) {
  echo "This is the author archive page for author ID 4.";
}

Check if the archive page for author with nickname ‘Vivian’ is being displayed

if ( is_author( 'Vivian' ) ) {
  echo "This is the author archive page for the author with nickname 'Vivian'.";
}

Check if the archive page for author with nicename ‘john-jones’ is being displayed

if ( is_author( 'john-jones' ) ) {
  echo "This is the author archive page for the author with nicename 'john-jones'.";
}

Check if the archive page for author matches multiple conditions

if ( is_author( array( 4, 'john-jones', 'Vivian' ) ) ) {
  echo "This is the author archive page for either user ID 4, user_nicename 'john-jones', or nickname 'Vivian'.";
}

Note: The array ability was added at Version 2.5.