get_the_author_posts_link() WordPress Function

The get_the_author_posts_link() function in WordPress displays a link to the author's posts page. The link is wrapped in an HTML element with the class attribute set to "vcard".

get_the_author_posts_link() #

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().


Top ↑

Return

(string) An HTML link to the author page, or an empty string if $authordata isn't defined.


Top ↑

Source

File: wp-includes/author-template.php

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

	$link = sprintf(
		'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
		esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
		/* translators: %s: Author's display name. */
		esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
		get_the_author()
	);

	/**
	 * Filters the link to the author page of the author of the current post.
	 *
	 * @since 2.9.0
	 *
	 * @param string $link HTML link.
	 */
	return apply_filters( 'the_author_posts_link', $link );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.