the_author()
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().
Uses: 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|null
. 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 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>
#2 Get the author's name using the get_the_author() function:
$author = get_the_author(); echo "The author of the post: ". $author;
Notes
- See: get_the_author()
Changelog
Since 0.71 | Introduced. |