the_author_meta() WordPress Function

The the_author_meta() function is used to display information about the author of the current post. This function can be used to display the author's name, website, bio, and other information.

the_author_meta( string $field = '', int|false $user_id = false ) #

Outputs the field from the user’s DB object. Defaults to current post’s author.


Description

Top ↑

See also


Top ↑

Parameters

$field

(string)(Optional)Selects the field of the users record. See get_the_author_meta() for the list of possible fields.

Default value: ''

$user_id

(int|false)(Optional) User ID.

Default value: false


Top ↑

More Information

This template tag displays a desired meta data field for a user. Only one field is returned at a time, you need to specify which you want.

If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop.

If the meta field does not exist, nothing is printed.

NOTE: Use get_the_author_meta() if you need to return (and do something with) the field, rather than just display it.

For parameter $userID, if the user ID fields is used, then this function display the specific field for this user ID.


Top ↑

Source

File: wp-includes/author-template.php

function the_author_meta( $field = '', $user_id = false ) {
	$author_meta = get_the_author_meta( $field, $user_id );

	/**
	 * Filters the value of the requested user metadata.
	 *
	 * The filter name is dynamic and depends on the $field parameter of the function.
	 *
	 * @since 2.8.0
	 *
	 * @param string    $author_meta The value of the metadata.
	 * @param int|false $user_id     The user ID.
	 */
	echo apply_filters( "the_author_{$field}", $author_meta, $user_id );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.