[wp-trac] [WordPress Trac] #38843: Add filter for post statuses in _update_post_term_count()
WordPress Trac
noreply at wordpress.org
Thu Nov 17 19:17:57 UTC 2016
#38843: Add filter for post statuses in _update_post_term_count()
-------------------------+-----------------------------
Reporter: GunGeekATX | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
`_update_post_term_count()` is hard-coded to only use the 'publish' status
when updating the post count for a term. The lack of a filter here does
not allow the term count to include other post statuses (or custom post
statuses) in situations where the user would like the term count to
reflect the other statuses.
Example of using proposed patch to allow 'future' status to be included in
Category term count.
{{{
add_filter( 'update_post_term_count_statuses', function( $post_statuses,
$taxonomy ) {
// Allow future statuses to be counted for Category post count.
if ( 'category' === $taxonomy->name ) {
$post_statuses[] = 'future';
}
return $post_statuses;
}, 10, 2 );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38843>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list