[wp-trac] [WordPress Trac] #15626: get_terms bug: pad_counts doesn't work if you specify parent

WordPress Trac wp-trac at lists.automattic.com
Wed Dec 1 13:40:49 UTC 2010


#15626: get_terms bug: pad_counts doesn't work if you specify parent
--------------------------+-------------------------------------------------
 Reporter:  yeswework     |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  3.1            
 Severity:  normal        |    Keywords:                 
--------------------------+-------------------------------------------------
 I'm not sure if this is related to #13176 or not.

 Anyway, to explain the bug with an example:

 Let's say you want to retrieve, via get_terms, a list of the top level
 categories only (by setting parent=0), but that you want the counts to
 include any posts assigned to subcategories too (pad_counts=1).

 $categories=get_terms('category', 'pad_counts=1&parent=0');

 This doesn't work: as soon as you specify parent=, it stops including the
 subcategory count within the parent categories. A bug, surely?

 I've traced the cause to line 842 of taxonomy.php, where it checks
 if ('' !== $args['parent'])
 and if so, sets pad_counts back to 0.

 Why is that check needed at all?

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


More information about the wp-trac mailing list