[wp-trac] [WordPress Trac] #53319: Add support for a "reverse" argument in get_term_parents_list() function

WordPress Trac noreply at wordpress.org
Wed Jun 2 10:36:36 UTC 2021


#53319: Add support for a "reverse" argument in get_term_parents_list() function
-------------------------+-----------------------------
 Reporter:  bedas        |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:  has-patch
  Focuses:               |
-------------------------+-----------------------------
 Please bare with me, I probably do everything wrong since it is my first
 Trac Ticket involving code.

 ---

 Recently I used `get_term_parents_list()` to create a list of hierarchical
 terms.
 I noticed that by default the function outputs the terms like so:
 `Parent Category/Child Category/Grandchild Category`

 I could not find any argument or way to invert that order, with the goal
 to display the terms like so:
 `Grandchild Category/Child Category/Parent Category`

 This is useful for example if we have Geographic zones and the utmost
 parent is a Country, the utmost child an area. In that case we may want to
 display Area/Region/Country which looks like an address structure rather
 than the opposed which is the default

 I don't think it should be too hard adding this new argument to the
 function.
 I have uploaded a file with the modified function and updated code comment
 to the ticket.

 I also tested my changes on a existing install and can confirm this
 introduced no unexpected issues.

 It would be awesome to see if we can add this tiny change in future
 release.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53319>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list