the_author() WordPress Function

The the_author() function is used to display the author of a post. The author is pulled from the post's author metadata.

the_author( string $deprecated = '', bool $deprecated_echo = true ) #

Displays the name of the author of the current post.


Description

The behavior of this function is based off of old functionality predating get_the_author(). This function is not deprecated, but is designed to echo the value from get_the_author() and as an result of any old theme that might still use the old behavior will also pass the value from get_the_author().

The normal, expected behavior of this function is to echo the author and not return it. However, backward compatibility has to be maintained.

Top ↑

See also


Top ↑

Parameters

$deprecated

(string)(Optional)Deprecated.

Default value: ''

$deprecated_echo

(bool)(Optional)Deprecated. Use get_the_author(). Echo the string or return it.

Default value: true


Top ↑

Return

(string|null) The author's display name, from get_the_author().


Top ↑

Source

File: wp-includes/author-template.php

function the_author( $deprecated = '', $deprecated_echo = true ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.1.0' );
	}

	if ( true !== $deprecated_echo ) {
		_deprecated_argument(
			__FUNCTION__,
			'1.5.0',
			sprintf(
				/* translators: %s: get_the_author() */
				__( 'Use %s instead if you do not want the value echoed.' ),
				'<code>get_the_author()</code>'
			)
		);
	}

	if ( $deprecated_echo ) {
		echo get_the_author();
	}

	return get_the_author();
}


Top ↑

Changelog

Changelog
VersionDescription
0.71Introduced.

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.