WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12908 closed enhancement (duplicate)

Introduce get_term_ancestors()

Reported by: scribu Owned by: filosofo
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

We have get_term_children(), but no get_term_ancestors().

It can be used in Core to cut down the queries done by cat_is_ancestor_of() and will be useful in and off itself. Example: #12898 #10277

Attachments (1)

get_term_ancestors.diff (1.7 KB) - added by scribu 4 years ago.
Introduce get_term_ancestors() and use in cat_is_ancestor_of()

Download all attachments as: .zip

Change History (5)

comment:1 follow-up: filosofo4 years ago

See #12443

That's an interesting approach, but I think you're going to eat up all the memory with a decent number of categories.

scribu4 years ago

Introduce get_term_ancestors() and use in cat_is_ancestor_of()

comment:2 voyagerfan57614 years ago

  • Cc WordPress@… added

comment:3 in reply to: ↑ 1 scribu4 years ago

Replying to filosofo:

That's an interesting approach, but I think you're going to eat up all the memory with a decent number of categories.

I don't think that's likely, since only two integer fields are retrieved: ID and parent.

Besides, wp_list_categories() retrieves all the fields for all the categories and I haven't heard any memory limit issues about that.

comment:4 scribu4 years ago

  • Milestone 3.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

I think #12443 is the better way to go.

Note: See TracTickets for help on using tickets.