wp_count_posts
Filter HookDescription
Filters the post counts by status for the current post type.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 3412 |
Hook Parameters
Type | Name | Description |
---|---|---|
stdClass
|
$counts
|
An object containing the current post_type's post counts by status. |
string
|
$type
|
Post type. |
string
|
$perm
|
The permission to determine if the posts are 'readable' by the current user. |
Usage Examples
Basic Usage
<?php
// Hook into wp_count_posts
add_filter('wp_count_posts', 'my_custom_filter', 10, 3);
function my_custom_filter($counts, $type, $perm) {
// Your custom filtering logic here
return $counts;
}
Source Code Context
wp-includes/post.php:3412
- How this hook is used in WordPress core
<?php
3407 * counts by status.
3408 * @param string $type Post type.
3409 * @param string $perm The permission to determine if the posts are 'readable'
3410 * by the current user.
3411 */
3412 return apply_filters( 'wp_count_posts', $counts, $type, $perm );
3413 }
3414
3415 /**
3416 * Counts number of attachments for the mime type(s).
3417 *
PHP Documentation
<?php
/**
* Filters the post counts by status for the current post type.
*
* @since 3.7.0
*
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.