[wp-trac] [WordPress Trac] #17955: Allow a single taxonomy to be passed to get_terms() as an array.

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 1 05:46:26 UTC 2011


#17955: Allow a single taxonomy to be passed to get_terms() as an array.
--------------------------+------------------------------------
 Reporter:  mfields       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  3.2
 Severity:  normal        |   Keywords:  has-patch dev-feedback
--------------------------+------------------------------------
 The inline docs for get_terms() state that the $taxonomies parameter may
 contain either a string or an array.

 {{{
 @param string|array $taxonomies Taxonomy name or list of Taxonomy names
 }}}

 I've just ran into a situation where this is not the case. The following
 code works fine and should list all children of the term with and id of
 174:


 {{{
 $terms = get_terms( 'category', array( 'child_of' => 174 ) );
 print '<pre>' . print_r( $terms, true ) . '</pre>';
 }}}

 However, if the taxonomies parameter is given in an array, all categories
 will be returned:


 {{{
 $terms = get_terms( array( 'category' ), array( 'child_of' => 174 ) );
 print '<pre>' . print_r( $terms, true ) . '</pre>';
 }}}

 I believe that both examples should produce the same results.

 This behavior can be observed in WordPress 3.1.4 as well as 3.2.

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


More information about the wp-trac mailing list