get_the_author_posts() - WordPress 函数参考中文文档

返回介绍

get_the_author_posts()

发布于 2017-09-11 字数1740 浏览 977 评论 0

get_the_author_posts()

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


描述


返回值

(int) The number of posts by the author.


源代码

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 );
}

更新日志

Version 描述
1.5.0 Introduced.

相关函数

Uses

  • wp-includes/user.php:
    count_user_posts()
  • wp-includes/post.php:
    get_post()

Used By

  • wp-includes/author-template.php:
    the_author_posts()

User Contributed Notes

  1. Skip to note content

    You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note

    Contributed by Codex

    Basic Example
    Displays the author’s name and number of posts.

    
    <p><?php the_author(); ?> has blogged <?php echo number_format_i18n( get_the_author_posts() ); ?> 
    posts</p>
    

    Output is “Harriett Smith has blogged 4,250 posts.”

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!