wp_count_posts
云策文档标注
概述
wp_count_posts 是一个 WordPress 过滤器,用于按状态过滤当前文章类型的文章计数。它允许开发者修改基于状态的文章数量统计。
关键要点
- 过滤器名称:wp_count_posts
- 参数:$counts(包含按状态计数的对象)、$type(文章类型)、$perm(用户权限)
- 用途:在 wp_count_posts() 函数中调用,用于调整文章计数结果
- 相关函数:wp_count_posts() 位于 wp-includes/post.php
注意事项
- 此过滤器自 WordPress 3.7.0 版本引入
- 使用时需确保正确处理权限参数以反映用户的可读性
原文内容
Filters the post counts by status for the current post type.
Parameters
$countsstdClass-
An object containing the current post_type’s post counts by status.
$typestring-
Post type.
$permstring-
The permission to determine if the posts are
'readable'by the current user.
Source
return apply_filters( 'wp_count_posts', $counts, $type, $perm );
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |