wp_count_posts


wp_count_posts ( $type = 'post', $perm = '' )

Parameters:
  • (string) $type Optional. Post type to retrieve count. Default 'post'.
  • (string) $perm Optional. 'readable' or empty. Default empty.
Returns:
  • (object) Number of posts for each status.
Defined at:

Description

Count number of posts of a post type and if user has permissions to view.

This function provides an efficient method of finding the amount of post's type a blog has. Another method is to count the amount of items in get_posts(), but that method has a lot of overhead with doing so. Therefore, when developing for 2.5+, use this function instead.

The $perm parameter checks for 'readable' value and if the user can read private posts, it will display that for the user that is signed in.

Related Functions

wp_count_terms, wp_count_comments, wp_untrash_post, count_user_posts, wp_get_recent_posts

Top Google Results

User discussions

wpseek mobile