Make WordPress Core

Opened 12 years ago

Closed 4 years ago

#8050 closed enhancement (wontfix)


Reported by: youngmicroserf Owned by: westi
Milestone: 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 9 years ago.
8050.1.patch (716 bytes) - added by kurtpayne 9 years ago.
Documenting return type

Download all attachments as: .zip

Change History (21)

#1 @westi
12 years ago

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

12 years ago

  • Milestone changed from 2.8 to Future Release

#3 @Denis-de-Bernardy
12 years ago

  • Component changed from General to Template

#4 @youngmicroserf
11 years ago

  • Milestone changed from Future Release to 3.0

Bumping this up.

#5 @dd32
11 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.

#6 @dd32
11 years ago

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

#7 @scribu
11 years ago

Related: #12443

#8 @scribu
11 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 ) );

#9 @voyagerfan5761
11 years ago

  • Cc WordPress@… added

#10 @filosofo
11 years ago

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

#11 @scribu
11 years ago

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

#12 @scribu
10 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

#13 @nacin
10 years ago

  • Milestone changed from Awaiting Triage to Future Release

Still just needs a patch.

#14 @nacin
10 years ago

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

9 years ago


#15 @kurtpayne
9 years ago

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

9 years ago

Documenting return type

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

7 years ago

#17 @nacin
7 years ago

  • Component changed from Template to General
  • Focuses template added

#18 @ericlewis
6 years ago

I can't imagine using this myself - anyone care to share a use-case?

#19 @swissspidy
4 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed

I can't imagine using this myself - anyone care to share a use-case?

Agreed. Especially since it's now just a 1-liner.

Closing as wontfix because of a lack of traction. Feel free to reopen when some valid use cases for themes, plugins, and/or core emerge.

Note: See TracTickets for help on using tickets.