get_the_author_posts()获取当前作者/用户发布的文章总数

目录

描述

Returns the total number of posts an author has published. Drafts and private posts aren't counted. This tag must be used within The Loop.

get_the_author_posts() 描述

用法

 <?php echo get_the_author_posts(); ?> 

get_the_author_posts() 用法

参数

This tag does not accept any parameters.

get_the_author_posts() 参数

历史

  • 添加于 版本: 1.5.0

get_the_author_posts() 历史

源文件

get_the_author_posts() 函数的代码位于 wp-includes/author-template.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Retrieve the number of posts by the author of the current post.
 *
 * @since 1.5.0
 *
 * @return int The number of posts by the author.
 */
function get_the_author_posts() {
	$post = get_post();
	if ( ! $post ) {
		return 0;
	}
	return count_user_posts( $post->post_author, $post->post_type );
}

get_the_author_posts() 源文件

相关