WordPress函数文档count_user_posts()

获取用户发布的文章数 描述 Returns the post count for a user. 用法 &lt…

获取用户发布的文章数

描述

Returns the post count for a user.

用法

<?php $user_post_count count_user_posts$userid $post_type ); ?>

参数

$userid

(integer) (必填) The ID of the user to count posts for.

默认值: None

$post_type

(string) (可选) Post type to count the number of posts for.

默认值: “post”

示例

Get post count for a user

Display the number of posts published by the user with an ID of 5.

Get post count for a user of post type

Display the number of posts of post type “book” published by the user with an ID of 5.

Translation friendly post count

The same operation, with translation support.

Result

The result of the above two examples

Number of posts published by user: 123

历史

  • 添加于 版本: 3.0.0
  • 添加于 版本: 4.1.0 (Added post type support)

源文件

count_user_posts() 函数的代码位于 wp-includes/user.php.

相关

count_many_users_posts,
get_posts_by_author_sql

  • 原文:http://codex.wordpress.org/Function_Reference/count_user_posts
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT