[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
Thu Nov 13 03:14:09 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:  Awaiting
Component:  Taxonomy                             |  Review
 Severity:  normal                               |     Version:  4.0
 Keywords:  good-first-bug has-patch needs-      |  Resolution:
  unit-tests                                     |     Focuses:
-------------------------------------------------+-------------------------

Comment (by theMikeD):

 Replying to [comment:13 boonebgorges]:
 > Instead of calling `get_terms()` again after identifying the leaf nodes,
 we should be appending the IDs to the `$inclusions` array, to keep the
 logical flow of the function. And actually, now that I think about it: the
 number of non-leaf nodes in most trees is likely to be lower than the
 number of leaves, so it might make sense to identify the *non* leaves and
 add them to `$exclusions` instead.

 That ''is'' better: any term listed as a top-level entry in the array
 returned by `_get_term_hierarchy()` is a non-leaf term by definition, so
 can be excluded.  That would skip the need to call `get_terms()` at all.
 Clever, I missed the `$exclusions` array the first time around.

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


More information about the wp-trac mailing list