[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 02:35:12 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 boonebgorges):
theMikeD - Thanks for the updated patch and for your continued attention
to this ticket. The general technique of checking `_get_term_hierarchy()`
seems smart to me.
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.
I'll also feel better about this when we have some unit tests that
demonstrate that the technique works for hierarchies that have more than 2
levels :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29839#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list