[wp-trac] [WordPress Trac] #30415: Add alternative to get_category_parents() that will work for any taxonomy

WordPress Trac noreply at wordpress.org
Fri Jan 30 06:54:24 UTC 2015


#30415: Add alternative to get_category_parents() that will work for any taxonomy
----------------------------------------+------------------------------
 Reporter:  hlashbrooke                 |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Taxonomy                    |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:
----------------------------------------+------------------------------

Comment (by hlashbrooke):

 Replying to [comment:12 boonebgorges]:
 > Thanks for the patches so far.
 >
 > I understand the motivation behind breaking `get_term_parents()` into a
 separate function from `get_term_parents_html()`. But this creates a
 disparity between `get_category_parents()`, which returns a string, and
 `get_term_parents()`, which returns an array of parents.

 That's a good point - it's frustrating when there's a disparity like that.

 > If we're going to have a general tool for getting ancestors of a term,
 I'd rather have it be a new parameter for `get_terms()`, and it would be
 more efficient for it to work by fetching the cached hierarchy with
 `_get_term_hierarchy()` instead of crawling backward with a `while` loop.
 (Notwithstanding what `get_category_parents()` already does :) )

 So in that case `get_terms()` would be able to return an array of
 ancestors and then the new `get_term_parents()` simply uses that to return
 an HTML string identical to `get_category_parents()`. I think that makes a
 lot of sense - I'll rework my patch here and upload a new one once it's
 done.

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


More information about the wp-trac mailing list