Using WordPress ‘get_the_author_link()’ PHP function

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
echo 'Written by: ' . get_the_author_link();
// Wrap the author's link in a paragraph
echo '<p>Author: ' . get_the_author_link() . '</p>';
// Wrap the author's link in a list item
echo '<li>' . get_the_author_link() . '</li>';
// 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 with custom text
$author_url = get_the_author_link();
echo '<a href="' . $author_url . '">Visit the author\'s website</a>';