[wp-trac] [WordPress Trac] #29839: Enhance get_terms to return only bottom child terms (terms without children) when taxonomy is heirarchical

WordPress Trac noreply at wordpress.org
Sun Dec 28 03:53:49 UTC 2014


#29839: Enhance get_terms to return only bottom child terms (terms without
children) when taxonomy is heirarchical
-------------------------------------------------+-------------------------
 Reporter:  theMikeD                             |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Taxonomy                             |  Release
 Severity:  normal                               |     Version:  4.0
 Keywords:  4.2-early has-patch needs-unit-      |  Resolution:
  tests 2nd-opinion                              |     Focuses:
-------------------------------------------------+-------------------------
Changes (by johnbillion):

 * keywords:  4.2-early has-patch => 4.2-early has-patch needs-unit-tests
     2nd-opinion


Comment:

 This will need unit tests.

 Also, the `foreach` loop in the patch can be replaced with something
 simpler, like this:

 `$terms_to_exclude = implode( ', ', array_map( 'absint', array_keys(
 $term_hierarchy ) ) );`

 Finally, I'm not entirely convinced this argument is very useful. It can
 be manually implemented with minimal code:

 {{{
 $terms = get_terms( $taxonomy, array(
   'exclude' => array_keys( _get_term_hierarchy( $taxonomy ) )
 ) );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29839#comment:58>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list