wp_count_posts
Filters the post counts by status for the current post type.
Usage
add_filter( 'wp_count_posts', 'wp_kama_count_posts_filter', 10, 3 );
/**
* Function for `wp_count_posts` filter-hook.
*
* @param stdClass $counts An object containing the current post_type's post counts by status.
* @param string $type Post type.
* @param string $perm The permission to determine if the posts are 'readable' by the current user.
*
* @return stdClass
*/
function wp_kama_count_posts_filter( $counts, $type, $perm ){
// filter...
return $counts;
}
- $counts(stdClass)
- An object containing the current post_type's post counts by status.
- $type(string)
- Post type.
- $perm(string)
- The permission to determine if the posts are 'readable' by the current user.
Changelog
| Since 3.7.0 | Introduced. |
Where the hook is called
wp_count_posts
wp-includes/post.php 3480
return apply_filters( 'wp_count_posts', $counts, $type, $perm );
wp-includes/post.php 3423
return apply_filters( 'wp_count_posts', $counts, $type, $perm );