the_author()WP 0.71

Display the name of the author of the current post.

Must be used inside WordPress Loop.

The behavior of this function is based on old functionality predating get_the_author(). This function is not deprecated but is designed to echo the value from get_the_author() and as a 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. If you need return the value to use further in php use get_the_author().

1 time — 0.000044 sec (very fast) | 50000 times — 0.49 sec (very fast) | PHP 7.1.2, WP 4.7.3

No Hooks.

Return

String. Display author name.

Usage

<?php the_author(); ?>

Old usage:

<?php the_author( $deprecated, $deprecated_echo ); ?>
$deprecated(string)
Deprecated.
Default: ''
$deprecated_echo(string)
Deprecated. Use get_the_author(). Echo the string or return it.
Default: true

Examples

1

#1 Get the author's name using the get_the_author() function:

$author = get_the_author();
echo "The author of the post: ". $author;
0

#2 Output the public name of the author of the post in the WordPress cycle

The public name is specified in the setting: "display as"

<p>The author of the post: <?php the_author(); ?></p>

Notes

Changelog

Since 0.71 Introduced.

the_author() code WP 6.5.2

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();
}