[Plugin: Category Cloud Widget] Code snippet that makes plugin count sub-categories posts as well
-
if ( function_exists('get_categories') ) { // new version of wp (2.1+) $cats = get_categories("style=cloud&show_count=1&use_desc_for_title=0$exclude&hierarchical=0$hide_empty"); foreach ($cats as $cat) { // Get current category's children $children = get_categories('show_count=1&child_of='.$cat->cat_ID); $child_count = 0; if ($children != '') { foreach ($children as $child) { // Count the childrens post and add to total sum $child_count = $child_count + $child->category_count; } } $catlink = get_category_link( $cat->cat_ID ); $catname = $cat->cat_name; $count = $cat->category_count; // Sum of count and all childrens counts $count = $count + $child_count; if ($count >= $options['min']) { $counts{$catname} = $count; $catlinks{$catname} = $catlink; } } }
https://www.ads-software.com/extend/plugins/widget-category-cloud/
- The topic ‘[Plugin: Category Cloud Widget] Code snippet that makes plugin count sub-categories posts as well’ is closed to new replies.