get_the_author_link()
Retrieve either author’s link or author’s name.
Description Description
If the author has a home page set, return an HTML link, otherwise just return the author’s name.
Return Return
(string|null) An HTML link if the author's url exist in user meta, else the result of get_the_author().
Source Source
File: wp-includes/author-template.php
function get_the_author_link() {
if ( get_the_author_meta( 'url' ) ) {
return sprintf(
'<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
esc_url( get_the_author_meta( 'url' ) ),
/* translators: %s: Author's display name. */
esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author() ) ),
get_the_author()
);
} else {
return get_the_author();
}
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
This example displays the author’s Website URL as a link and the text for the link is the author’s Profile Display Name. In this example, the author’s Display Name is James Smith.
Which displays as:
Written by: James Smith