WPDev.one
Core Function
View Source on Trac ↗

count_user_posts()

count_user_posts( mixed $userid, mixed $post_type = 'post', mixed $public_only = false )

Gets the number of posts a user has written.

Parameters 2 required

Name / Type Description
$userid
int

User ID.

Required
(array

| string) $post_type Optional. Single post type or array of post types to count the number of posts for. Default 'post'.

Required
$public_only
bool

Optional. Whether to only return counts for public posts. Default false.

Return Value

(string)
Number of posts the user has written in this post type.

Function Information

Since Version
3.0.0
Source File
wp-includes/user.php
Advertisement