bool is_child ( mixed parent [, bool recursive] )

  • mixed parent can be either integer or string, submitting a post/page/category ID or title or slug you want to check the relationship to.
  • bool recursive can be either true for a recursive search or false, so only the direct parents of the current item will be checked. Default is true.

The returned value will be true if the current item is a child of mixed parent or false if it’s not.

What it does:
is_child offers the possibility to check out if the current post, page or category is a child item of a specific category or page. This comes in handy if you i.e. want to have a special sidebar throughout a category and all of its subs as well as all containing postings in there. Or maybe you’d want to turn your WordPress installation into a CMS using Pages, offering some special features throughout a hierarchy. WordPress currently does not offer this function (but sure will somewhere in the future), so you might find this plugin useful until then.


is_child( 10 )
Checks if the current page, posting or category is somehow related to category- (or page-)ID 10.

is_child( "Example Category", false )
Checks if the current element is a direct child of “Example Category”.

is_child( "some-page", 1 )
Checks if the current page is somehow related to a page with the slug “some-page”.

A more detailed example:

Assume you’re here:
Music -> CDs -> Artists -> JAMMIN*INC -> Mit Anlauf

Now you want to place some Amazon Ads throughout the whole Music category and all of it’s content. Easy as pie:
if( is_child( "Music" ) ) include( "amazon-ads.php" );

There you go. Guess there are even more possibilites which I haven’t thought of. If so, please share your ideas in the comment section.

Go ahead and fetch it here:

Extract is_child.php from the .zip-archive and place it in your WordPress plugin-folder. Then browse to your administration menu named “Plugins” and activate the plugin. That’s it.


1.1.2 Fixed a bug which ended up in seldomly sending an invalid SQL-query when browsing archives.
1.1.1 Fixed a bug that resulted in getting wrong page IDs from SQL-queries.
1.1.0 Added checking for parental pages.
1.0.0 Final Release.
0.5.0 No more catlooping. All categories in queue are now handled with one single query to boost up performance. Catching IDs if zero, as they’re always true.
0.4.0 Now being able to look for category name or slug instead of the plain ID.
0.3.0 Automated detection of category, page or single posting.
0.2.0 Added recursive search.
0.1.0 Initial Test Release.