Home WordPress Author Functions the_author_meta() Definition In WordPress, the_author_meta() prints one profile field of an author. For example, the display name, the bio, or the first name.
Pass the field name. Inside The Loop it uses the current post author. Outside The Loop, pass a user ID as the second value. To get the value as a string, use get_the_author_meta().
Syntax Give the field name. Add a user ID if you are not inside The Loop.
the_author_meta( $field );
the_author_meta( $field, $user_id ); Call What it does the_author_meta( 'description' )Prints the bio of the current post author. the_author_meta( 'first_name', 1 )Prints the first name of the user with ID 1.
Use get_the_author_meta() when you need the value instead of printing it.
Full declaration the_author_meta( string $field = '', int|false $user_id = false ): void Parameters Parameter Description $fieldRequired in practice. The profile field name, for example display_name. $user_idOptional. The user ID. Leave it out to use the current post author.
Common field names Field What it holds display_nameThe public name. first_name, last_nameFirst and last name. nicknameThe nickname from the profile. descriptionThe bio. user_urlThe website. user_emailThe email address. Do not show it publicly. IDThe user ID number.
Return Value Return Value Description void (prints to the page) The function prints the field value. Its twin get_the_author_meta() returns it.
WordPress Examples Three short theme examples. Each one has a sample output.
1. Display name 2. Author bio 3. Author archive title Example 1 — Display name Print the display name with the field name.
<p>By <?php the_author_meta( 'display_name' ); ?></p> How It Works The field name is display_name. No user ID is passed, so the current post author is used. The value is printed in place. Example 2 — Author bio Show the bio below a post.
<div class="author-box">
<h3><?php the_author_meta( 'display_name' ); ?></h3>
<p><?php the_author_meta( 'description' ); ?></p>
</div> Mari Selvan
I write about WordPress and PHP. How It Works description is the Biographical Info field in the profile.Each call prints one value. Wrap them in your own HTML for styling. Example 3 — Author archive title On author.php there is no current post, so pass the user ID.
<h1>
Posts by
<?php the_author_meta( 'display_name', get_queried_object_id() ); ?>
</h1> How It Works get_queried_object_id() returns the author ID on an author archive.The ID is the second value. The display name of that user is printed. Frequently Asked Questions What does the_author_meta() do? It prints one profile field of an author, such as display_name or description.
What is the difference between the_author_meta() and get_the_author_meta()? the_author_meta() prints the field. get_the_author_meta() returns it so you can store or escape it.
How do I show the author bio? Use the_author_meta( 'description' ).
How do I use it on an author archive page? Pass the user ID: the_author_meta( 'display_name', get_queried_object_id() ).
Is it safe to print user_email? Avoid it on public pages. Showing email addresses can lead to spam.
Can I read custom user fields? Yes. Pass the meta key name as the field, if your plugin or theme stored a custom field on the user.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful
Helpful Share Copy link Suggestion