Make WordPress Core

Opened 19 months ago

Last modified 19 months ago

#38843 new enhancement

Add filter for post statuses in _update_post_term_count()

Reported by: GunGeekATX Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


_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 );

Attachments (1)

38843.patch (1.9 KB) - added by GunGeekATX 19 months ago.
Proposed patch with filter

Download all attachments as: .zip

Change History (2)

19 months ago

Proposed patch with filter

#1 @GunGeekATX
19 months ago

  • Keywords has-patch added
Note: See TracTickets for help on using tickets.