Each and every blog posts and pages in WordPress is written by a author or blogger, and hence has an author ID associated with it. Within the loop, the_author_meta(‘ID’); (previously the_author_ID();) template tag and the_author(); or get_the_author(); functions can be used to retrieve, obtain or get the author ID and profile for further manipulation, though must be inside the loop of WordPress.

Outside the loop, the_author_meta( $field, $userID ); can be specified with a author ID or user ID in order to return the name and profile meta of the user. However, as it’s outside of the loop, the author ID must first be obtained in order to feed the the_author_meta function.

Here’s how to obtain and get the author ID outside the WordPress loop:

<?php
global $post;
$author_id=$post->post_author;
?>

Then, in order to retrieve name or other meta profile of the author ID, just use the the_author_meta(); template tag:

<?php
$field=’meta name‘;
the_author_meta( $field, $author_id );
?>

Replace meta name with a valid parameter that available as field name. The $field represent a meta data that associate with the author or user, such as login name, display name, nickname, and etc. List of valid values for the field name includes:

  • user_login
  • user_pass
  • user_nicename
  • user_email
  • user_url
  • user_registered
  • user_activation_key
  • user_status
  • display_name
  • nickname
  • first_name
  • last_name
  • description
  • jabber
  • aim
  • yim
  • user_level
  • user_firstname
  • user_lastname
  • user_description
  • rich_editing
  • comment_shortcuts
  • admin_color
  • plugins_per_page
  • plugins_last_view
  • ID

The code above also supports a multi-users WordPress blog where there is multiple authors. Note that the code should be used on a single post or page templates, and can be used in sidebar, plugin, widget, theme function and other areas.