get_the_author()
Gets the name (display_name) of the post author. Used inside the WordPress loop.
Used By: get_the_author_posts_link(), the_author()
Hooks from the function
Returns
String. The displayed name of the author (display_name) or an empty string if display_name is not specified.
Usage
$author = get_the_author();
Examples
#1 Display the display_name (public name) of the author of current post:
$author = get_the_author(); echo $author;
Notes
- Global. WP_User. $authordata The current author's data.
Changelog
| Since 1.5.0 | Introduced. |
| Since 6.3.0 | Returns an empty string if the author's display name is unknown. |
get_the_author() get the author code WP 6.9
function get_the_author( $deprecated = '' ) {
global $authordata;
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.1.0' );
}
/**
* Filters the display name of the current post's author.
*
* @since 2.9.0
*
* @param string $display_name The author's display name.
*/
return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : '' );
}