On this page
get_the_author_link(): string|null
Retrieves either author’s link or author’s name.
Description
If the author has a home page set, return an HTML link, otherwise just return the author’s name.
Return
string|null An HTML link if the author's url exist in user meta, else the result of get_the_author() .
Source
File: wp-includes/author-template.php. View all references
function get_the_author_link() {
if ( get_the_author_meta( 'url' ) ) {
global $authordata;
$author_url = get_the_author_meta( 'url' );
$author_display_name = get_the_author();
$link = sprintf(
'<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
esc_url( $author_url ),
/* translators: %s: Author's display name. */
esc_attr( sprintf( __( 'Visit %s’s website' ), $author_display_name ) ),
$author_display_name
);
/**
* Filters the author URL link HTML.
*
* @since 6.0.0
*
* @param string $link The default rendered author HTML link.
* @param string $author_url Author's URL.
* @param WP_User $authordata Author user data.
*/
return apply_filters( 'the_author_link', $link, $author_url, $authordata );
} else {
return get_the_author();
}
}
Hooks
- apply_filters( 'the_author_link',
string $link ,string $author_url ,WP_User $authordata ) -
Filters the author URL link HTML.
Related
Uses
| Uses | Description |
|---|---|
| get_the_author_meta() wp-includes/author-template.php | Retrieves the requested data of the author of the current post. |
| get_the_author() wp-includes/author-template.php | Retrieves the author of the current post. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| esc_url() wp-includes/formatting.php | Checks and cleans a URL. |
| esc_attr() wp-includes/formatting.php | Escaping for HTML attributes. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| the_author_link() wp-includes/author-template.php | Displays either author’s link or author’s name. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_the_author_link