The get_the_author_link() WordPress PHP function retrieves either the author’s link or author’s name.
Usage
To use the get_the_author_link() function, simply include it in your PHP code within your WordPress theme.
echo get_the_author_link();
Parameters
- None
More information
See WordPress Developer Resources: get_the_author_link()
Examples
Display the author’s link with the text “Written by: Author Name”
// Display the author's link echo 'Written by: ' . get_the_author_link();
Display the author’s link in an HTML paragraph
// Wrap the author's link in a paragraph echo '<p>Author: ' . get_the_author_link() . '</p>';
Display the author’s link in an HTML list item
// Wrap the author's link in a list item echo '<li>' . get_the_author_link() . '</li>';
Display the author’s link inside an HTML div with a specific class
// Wrap the author's link in a div with a specific class echo '<div class="author-link">' . get_the_author_link() . '</div>';
Display the author’s link as a hyperlink with custom text
// Display the author's link with custom text $author_url = get_the_author_link(); echo '<a href="' . $author_url . '">Visit the author\'s website</a>';