diff options
Diffstat (limited to 'wp-includes/category.php')
-rw-r--r-- | wp-includes/category.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/wp-includes/category.php b/wp-includes/category.php index 3127482..648ef4f 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -67,7 +67,7 @@ function &get_categories($args = '') { $exclusions = apply_filters('list_cats_exclusions', $exclusions, $r ); $where .= $exclusions; - if ( $hide_empty ) { + if ( $hide_empty && !$hierarchical ) { if ( 'link' == $type ) $where .= ' AND link_count > 0'; else @@ -103,6 +103,22 @@ function &get_categories($args = '') { if ( $child_of || $hierarchical ) $categories = & _get_cat_children($child_of, $categories); + // Update category counts to include children. + if ( $hierarchical ) { + foreach ( $categories as $k => $category ) { + $progeny = $category->category_count; + if ( $children = _get_cat_children($category->cat_ID, $categories) ) { + foreach ( $children as $child ) + $progeny += $child->category_count; + } + if ( !$progeny && $hide_empty ) + unset($categories[$k]); + else + $categories[$k]->category_count = $progeny; + } + } + reset ( $categories ); + return apply_filters('get_categories', $categories, $r); } |