#4948 closed enhancement (worksforme)
Category Parent/Child Tree
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | Taxonomy | Version: | 2.2.3 |
| Severity: | minor | Keywords: | |
| Cc: |
Description
Short of building my own recursive function, I'd like WordPress to support a method to get a parent/child category ID tree. One function (get_category_parents) already does this except with the names of the categories. Another function, cat_is_ancestor_of in category.php appears to be usable, but I've been unable to get it to work.
In short, I'm trying to solve the problem of figuring out what top-most parent category a blog entry belongs to so that I can do some various things with CSS, sidebars, etc.
Change History (8)
- Component changed from General to Template
- Keywords needs-patch added
- Component changed from Template to Taxonomy
- Priority changed from normal to low
- Severity changed from normal to minor
isn't this what child_of does in get_terms() et al?
comment:7
wonderboymusic — 9 months ago
- Keywords needs-patch removed
- Resolution set to worksforme
- Status changed from new to closed
Use this:
$tree = get_terms( 'category', array( 'get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent' ) );
You can pass 'slug' => 'my-slug' for context
Note: See
TracTickets for help on using
tickets.

No Patch. Moved to 2.7