get_the_author_link()
Retrieve either author's link or author's name.
If the author has a home page set, return an HTML link, otherwise just return the author's name.
Used By: the_author_link()
Hooks from the function
Return
String|null
. An HTML link if the author's url exist in user meta, else the result of get_the_author().
Usage
get_the_author_link();
Examples
#1 Display the post author’s Website URL as a link
The link text will be the author's name, which is specified in the "Display name" field in the profile.
<p>Written by <?php echo get_the_author_link(); ?></p>
We get it:
Written by: <a href="https://{author_site}">James</a>
or
Written by: James
if the author does not have a website listed.
Notes
- Global. WP_User. $authordata The current author's data.
Changelog
Since 3.0.0 | Introduced. |