The get_the_author() WordPress PHP function retrieves the author of the current post. This function is deprecated.
Usage
$author_name = get_the_author();
Parameters
- $deprecated (string) Optional. Deprecated parameter. Default: ”
More information
See WordPress Developer Resources: get_the_author()
This function is deprecated. Consider using get_the_author_meta() instead.
Examples
Display author’s name in a blog post
This example retrieves and displays the author’s name in a blog post.
// Get the author's name $author_name = get_the_author(); // Display the author's name echo "Written by " . $author_name;
Display author’s name with a link to their archive
This example retrieves the author’s name and displays it with a link to their archive page.
// Get the author's name and URL $author_name = get_the_author(); $author_url = get_author_posts_url(get_the_author_meta('ID')); // Display the author's name with a link to their archive echo '<a href="' . $author_url . '">' . $author_name . '</a>';
Display author’s name with their avatar
This example retrieves the author’s name and displays it along with their avatar.
// Get the author's name and avatar $author_name = get_the_author(); $author_avatar = get_avatar(get_the_author_meta('ID')); // Display the author's name with their avatar echo $author_avatar . " " . $author_name;
Display author’s name with a custom CSS class
This example retrieves the author’s name and displays it with a custom CSS class.
// Get the author's name $author_name = get_the_author(); // Display the author's name with a custom CSS class echo '<span class="author-name">' . $author_name . '</span>';
Display author’s name and their bio
This example retrieves the author’s name and bio, then displays them together.
// Get the author's name and bio $author_name = get_the_author(); $author_bio = get_the_author_meta('description'); // Display the author's name and bio echo "Written by " . $author_name . "<br>"; echo "About the author: " . $author_bio;