wpseek.com
A WordPress-centric search engine for devs and theme authors



pre_wp_count_posts › WordPress Filter Hooks

Since7.2.0
Deprecatedn/a
› apply_filters( 'pre_wp_count_posts', null, $type, $perm )
Parameters: (3)
  • () counts An object containing the post counts by status, or null to run the default query. Default null.
    Required: Yes
  • () type Post type.
    Required: Yes
  • () perm The permission to determine if the posts are 'readable' by the current user.
    Required: Yes
Defined at:
Codex:

Filters the post counts before the query is run.

Returning a non-null value short-circuits wp_count_posts(), skipping both the object cache lookup and the database query. This allows the counts to be served from another source, such as a value pre-computed in the background, when an exact real-time count is not required. Any registered post status missing from the filtered value are added to the result and set to zero. The returned value is not cached and passed through the {@see 'wp_count_posts'} filter.




Source

$counts = apply_filters( 'pre_wp_count_posts', null, $type, $perm );