Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function categoryChecklist( $child_of, $selected_cats )
- {
- $walker = new Walker_Category_Checklist;
- $child_of = (int) $child_of;
- $args = array();
- $args['selected_cats'] = $selected_cats;
- $args['popular_cats'] = array();
- //$categories = get_categories( "child_of=$child_of&hierarchical=0&hide_empty=0" );
- $categories = get_categories( "child_of=$child_of&hierarchical=0&hide_empty=0" );
- $checked_categories = array();
- for ( $i = 0; isset($categories[$i]); $i++ ) {
- if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
- $checked_categories[] = $categories[$i];
- unset($categories[$i]);
- }
- }
- $null_categories = array();
- for ( $i = 0; isset($categories[$i]); $i++ ) {
- if ( in_array($categories[$i]->count, $args['']) ) {
- $null_categories[] = $categories[$i];
- unset($categories[$i]);
- }
- }
- // // Put checked cats on top
- // echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
- // // Then the rest of them
- // echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
- echo call_user_func_array(array(&$walker, 'walk'), array($null_categories, 0, $args));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement