This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_the_author_meta/
Languages: English • 日本語 (Add your language)
This function returns a single meta data for a user. All meta data is available, but you must specify which field you want.
If used within The Loop, the user ID need not be specified, it defaults to current post author. A user ID must be specified if used outside The Loop.
get_the_author_meta() returns the data for use programmatically in PHP. To just display it instead, use the_author_meta()
If the specified meta field does not exist for this user, an empty string is returned.
<?php get_the_author_meta( $field, $userID ); ?>
Get the email address for the author of the current post and store it in the $user_email variable for further use. (Remember, this function returns data, it doesn't display it.)
<?php $user_email = get_the_author_meta( 'user_email' ); ?>
Get the email address for user ID 25, and echo it using their display name as the anchor text.
<p>Email the author: <a href="mailto:<?php echo get_the_author_meta( 'user_email', 25 ); ?>"><?php the_author_meta( 'display_name', 25 ); ?></a></p>
Plugins may add additional fields to the user profile, which in turn adds new key/value pairs to the wp_usermeta database table. This additional data can be retrieved by passing the field's key to the function as the $field parameter.
Since: 2.8.0
get_the_author_meta() is located in wp-includes/author-template.php.
the_author(), get_the_author(), get_the_author_id(), the_author_link(), get_the_author_link(), the_author_meta(), get_the_author_meta(), the_author_posts(), get_the_author_posts(), the_author_posts_link(), get_author_posts_url(), get_the_modified_author(), the_modified_author(), wp_dropdown_users(), wp_list_authors()