Make WordPress Core

Opened 18 months ago

Last modified 18 months ago

#56892 new defect (bug)

wp_xx_categories() doesn't pad counts correctly when a sub-category exists

Reported by: wildworks's profile wildworks Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

I fond this issue while researching gutenberg #37319(https://github.com/WordPress/gutenberg/issues/37319).

If I set the hierarchical and show_count of wp_list_categories or wp_dropdown_categories to true, the counts for some categories aren't displayed correctly when there are posts that have grandchild categories.

Example:


wp_list_categories( array( 'show_count' => true, 'hierarchical' => true ) );
  • Parent (4)
    • Child 1 (3)
      • Grandchild 1 (1)
    • Child 2 (1)

wp_list_categories( array( 'show_count' => true, 'hierarchical' => false ) );
  • Child 1 (2)
  • Child 2 (1)
  • Grandchild 1 (1)

"Child 1" category counts are different, but the second data (hierarchical is false) is correct in my test data.
For some reason, I think the number of grandchild categories is counted as well.

This problem is the same when I output with wp_dropdown_categories.

Change History (1)

#1 @SergeyBiryukov
18 months ago

  • Component changed from General to Taxonomy
Note: See TracTickets for help on using tickets.