Make WordPress Core

Opened 5 months ago

#47314 new feature request

Add "parent" parameter to get_term_by

Reported by: leogermani Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:
PR Number:


There has been some discussion around some inconsistencies in the way term_exists() handles the input string and sometimes can have unexpeceted results. The most recent discussions about this can be seen in #47099, #45333 and #32248.

The current recommendation is to use get_term_by() instead, so you can explicitly inform what field you are checking and get the right result.

However, get_term_by() does not support a parent argument, which makes it not a full term_exists() replacement.

In #47099 @boonebgorges suggested we opened an enhancement ticket to discuss this addition to this function. And here it is! :)

Looking at the function and all parameters it gets, we would have to decide how to support this.

This would be the first question to ask if one was to try an approach for this. Adding as a new parameter does not look so good because there already many and it would force the developer to use all of them if he/she wanted to use parent. However adding support for a field like name_and_parent or something like this, and having an array passed as the $value doesn't look so pretty either.

What do you think?

Change History (0)

Note: See TracTickets for help on using tickets.