Home WordPress Author Functions get_the_author_link() WordPress get_the_author_link() Function Definition In WordPress, get_the_author_link() returns an HTML link (<a>) to the author's website. The website comes from the author profile (the user_url field).
The link text is the author display name. If the author has no website, the function returns just the name with no link.
Syntax Call it with no arguments and echo the result.
get_the_author_link();
echo get_the_author_link(); Call What it does get_the_author_link()Returns the link, or the plain name when there is no website. echo get_the_author_link()Prints the returned HTML.
The result is already HTML. Do not wrap it in esc_html(), or you will see the tags on the page.
Full declaration get_the_author_link(): string Parameters Parameter Description None This function takes no arguments. It reads the author of the current post.
Return Value Return Value Description string (link) An <a> tag that points to the author website. The text is the display name. string (name) Only the display name, when the author has no website.
WordPress Examples Three short theme examples. Each one has a sample output.
1. Author with website 2. No website 3. Byline Example 1 — Author with a website Print the link for an author who added a website to their profile.
<?php echo get_the_author_link(); ?> <a href="https://example.com/mari" title="Visit Mari Selvan’s website" rel="author external">Mari Selvan</a> How It Works WordPress reads the author website from the profile. It builds an <a> tag with the display name as text. echo prints the HTML.Example 2 — Author without a website If the profile has no website, you only get the name.
<?php echo get_the_author_link(); ?> How It Works The author "Riya Das" left the website field empty. WordPress falls back to get_the_author(). No link is created. Example 3 — Byline with a link Use the link inside your own HTML.
<span class="byline">
By <?php echo get_the_author_link(); ?>
</span> By <a href="https://example.com/mari" title="Visit Mari Selvan’s website" rel="author external">Mari Selvan</a> How It Works The text "By" is your own HTML. The link comes from get_the_author_link(). This is a common byline pattern in themes. Frequently Asked Questions What does get_the_author_link() return? It returns an HTML link to the author website, with the display name as the link text. If there is no website, it returns only the name.
Where does the website URL come from? It comes from the Website field in the author user profile (user_url).
Does get_the_author_link() print anything? No. It returns a string. Use echo, or use the_author_link() to print.
Should I use esc_html() on the result? No. The result is HTML, so esc_html() would show the tags as text.
How do I link to the author archive instead? Use the_author_posts_link(), or build your own link with get_author_posts_url().
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful
Helpful Share Copy link Suggestion