count_many_users_posts()
Number of posts written by a list of users.
No Hooks.
Return
String[]
. Amount of posts each user has written, as strings, keyed by user ID.
Usage
count_many_users_posts( $users, $post_type, $public_only );
- $users(int[]) (required)
- Array of user IDs.
- $post_type(string|string[])
- Single post type or array of post types to check.
Default: 'post' - $public_only(true|false)
- Only return counts for public posts.
Default: false
Examples
#1 How to get the number (count) of users posts
$users = [ 1, 141 ]; $counts = count_many_users_posts( $users ); print_r( $counts ); /* Array ( [1] => 157 [141] => 15 ) */
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 3.0.0 | Introduced. |