get_the_author_posts_link(): string

In this article

Retrieves an HTML link to the author page of the current post’s author.

Description

Returns an HTML-formatted link using get_author_posts_url() .

Return

string An HTML link to the author page, or an empty string if $authordata is not set.

Source

function get_the_author_posts_link() {
	global $authordata;

	if ( ! is_object( $authordata ) ) {
		return '';
	}

	$author = get_the_author();
	/* translators: %s: Author's display name. */
	$title = sprintf( __( 'Posts by %s' ), $author );

	$link = sprintf(
		'<a href="%1$s" rel="author">%2$s</a>',
		esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
		$author
	);

	/**
	 * Filters the link to the author page of the author of the current post.
	 *
	 * @since 2.9.0
	 * @since 7.0.0 Added `$author` and `$title` parameters.
	 *
	 * @param string $link   HTML link.
	 * @param string $author Author's display name.
	 * @param string $title  Text originally used for a title attribute.
	 */
	return apply_filters( 'the_author_posts_link', $link, $author, $title );
}

Hooks

apply_filters( ‘the_author_posts_link’, string $link, string $author, string $title )

Filters the link to the author page of the author of the current post.

Changelog

VersionDescription
7.0.0Removed title attribute.
4.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.