• Resolved mhhenn

    (@mhhenn)


    I been trying to use the exclude_tree on wp_list_categories but it just doesn’t work. If I use hide_empty=1(means hide empty categories) the exclude=”id” does delete the tree, but I need to show the empty categories and delete a tree. I read as well this fix on http://core.trac.wordpress.org/ticket/12981 but I didn’t really get the documentation…

    Does any one know a way around or the “fixed away” to use exclude_tree and have the “hide_empty=0″(show empty categories) on wp_list_categories?

    Any help will be appreciated.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mhhenn

    (@mhhenn)

    Anyone?

    Assuming 15 is id of the parent of the tree you want to exclude

    <?php
    $term_list = '';
    $taxonomy = 'category';
    $term_args=array(
      'child_of' => 15
    );
    $terms = get_terms($taxonomy,$term_args);
    
    if ($terms) {
      foreach( $terms as $term ) {
        $term_list .= $term->term_id . ',';
      }
      $term_list .= '15';
      wp_list_categories('hide_empty=0&exclude='.$term_list);
    }
    ?>
    Thread Starter mhhenn

    (@mhhenn)

    Thank you again Michael. I had kind of lost all my hopes on this one. Unfortunately is quite late now for me, so I will have to test it tomorrow.

    Thank you for your time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘exclude_tree wp_list_categories not working’ is closed to new replies.