[wp-trac] [WordPress Trac] #56892: wp_xx_categories() doesn't pad counts correctly when a sub-category exists

WordPress Trac noreply at wordpress.org
Sun Oct 23 10:15:35 UTC 2022


#56892: wp_xx_categories() doesn't pad counts correctly when a sub-category exists
--------------------------+-----------------------------
 Reporter:  wildworks     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56892>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list