[wp-trac] [WordPress Trac] #14446: get_terms exclusions does not work w/ empty child_of taxonomies

WordPress Trac wp-trac at lists.automattic.com
Wed Jul 28 20:05:35 UTC 2010


#14446: get_terms exclusions does not work w/ empty child_of taxonomies
--------------------------+-------------------------------------------------
 Reporter:  layotte       |       Owner:                          
     Type:  defect (bug)  |      Status:  new                     
 Priority:  normal        |   Milestone:  Awaiting Review         
Component:  Taxonomy      |     Version:  3.0                     
 Severity:  normal        |    Keywords:  has_patch, needs_testing
--------------------------+-------------------------------------------------
 Just ran into this problem, I created a category heirarchy:

 {{{
 Departments
 - ESSE
 - KINS
 - CSSE
 - WELSF
 }}}

 But I did not want the category tree to show up in the category list. So I
 modified the wp_list_categories statement to be:

 {{{
 <?php wp_list_categories('title_li=&hide_empty=0&exclude=3878,3877'); ?>
 }}}

 3878 is the category ID of "Departments", it was excluding "Departments"
 without a problem, but was listing the children of Departments. At first I
 thought this might be a heirarchy vs. exlude_tree problem, then I realized
 that the problem was that these were newly created Categories and they
 were empty.

 Currently during the exclusion process for $exclude_tree is to:

 {{{
 $excluded_children = (array) get_terms($taxonomies[0], array('child_of' =>
 intval($extrunk), 'fields' => 'ids' ));
 }}} (line 925 of taxonomy.php)

 This was returning an empty array because all the children were empty. My
 diff fixes this by adding 'hide_empty' => 0 to the get_terms command. If
 we're looking for children to exclude, we probably want to exclude the
 empty ones too :).

 Diff attached.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14446>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list