Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#8050 accepted enhancement


Reported by: youngmicroserf Owned by: westi
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: template Cc:


Is there any reason why there is no native is_child(direct,in_tree) function for hierarchical structures in WP (like pages, categories, custom hierarchical taxonomies)? There's a (partly) working plugin available at


but I think this amounts to a core functionality, particularly for people using WP as a hierarchical CMS.

Attachments (2)

8050.patch (698 bytes) - added by kurtpayne 3 years ago.
8050.1.patch (716 bytes) - added by kurtpayne 3 years ago.
Documenting return type

Download all attachments as: .zip

Change History (19)

comment:1 westi5 years ago

  • Owner changed from anonymous to westi
  • Status changed from new to assigned

comment:2 FFEMTcJ5 years ago

  • Milestone changed from 2.8 to Future Release

comment:3 Denis-de-Bernardy5 years ago

  • Component changed from General to Template

comment:4 youngmicroserf4 years ago

  • Milestone changed from Future Release to 3.0

Bumping this up.

comment:5 dd324 years ago

  • Keywords needs-patch added; is_child CMS selection removed
  • Milestone changed from 3.0 to 3.1

Unfortunately this has missed the boat for 3.0 as we're in a feature freeze.

I'm not setting this to 3.1 due to there not being a patch. If someone provides a patch, it may be in 3.1.

comment:6 dd324 years ago

...And there i go setting it to 3.1 anyway... I'll leave it in 3.1 for now.

comment:7 scribu4 years ago

Related: #12443

comment:8 scribu4 years ago

If we get #12443 in, is_child() would be as simple as:

function is_child( $child, $parent, $object_type ) {
    return in_array( $parent, get_ancestors( $child, $object_type ) );

comment:9 voyagerfan57614 years ago

  • Cc WordPress@… added

comment:10 filosofo4 years ago

There's no need to have both is_descendant and is_ancestor, right?

comment:11 scribu4 years ago

No, they're the same, except the parameter order would be different.

comment:12 scribu4 years ago

I was about to make cat_is_ancestor_of() use get_ancestors().

Then I realized that cat_is_ancestor_of(), as it is now, will stop once it finds a match, whereas get_ancestors() wouldn't.

So yeah, disregard comment:8

comment:13 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

Still just needs a patch.

comment:14 nacin3 years ago

That said, we should probably avoid is_* as it isn't a conditional tag.

kurtpayne3 years ago


comment:15 kurtpayne3 years ago

  • Cc kpayne@… added
  • Keywords has-patch added; needs-patch removed

kurtpayne3 years ago

Documenting return type

comment:16 ircbot3 months ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.

comment:17 nacin3 months ago

  • Component changed from Template to General
  • Focuses template added
Note: See TracTickets for help on using tickets.