get_the_author_posts() WordPress Function

The get_the_author_posts() function in WordPress allows you to retrieve the number of posts published by a given author. This can be useful for displaying statistics on an author's contributions, or for creating a list of popular authors on your site.

get_the_author_posts() #

Retrieves the number of posts by the author of the current post.


Return

(int) The number of posts by the author.


Top ↑

Source

File: wp-includes/author-template.php

function get_the_author_posts() {
	$post = get_post();
	if ( ! $post ) {
		return 0;
	}
	return count_user_posts( $post->post_author, $post->post_type );
}


Top ↑

Changelog

Changelog
VersionDescription
1.5.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.