Advertisement
mogaj

nullcategories

Jun 24th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. function categoryChecklist( $child_of, $selected_cats )
  2.     {
  3.         $walker = new Walker_Category_Checklist;
  4.         $child_of = (int) $child_of;
  5.        
  6.         $args = array();
  7.         $args['selected_cats'] = $selected_cats;
  8.         $args['popular_cats'] = array();
  9.         $categories = get_categories( "child_of=$child_of&hierarchical=0&hide_empty=0" );
  10.  
  11.         $null_categories = array();
  12.         for ( $i = 0; isset($categories[$i]); $i++ ) {
  13.             if (($categories[$i]->category_count) ) {
  14.                 $null_categories[] = $categories[$i];
  15.                 unset($categories[$i]);
  16.             }
  17.         }
  18.         echo call_user_func_array(array(&$walker, 'walk'), array($null_categories, 0, $args));
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement