Does your theme have children?

When working with WordPress theme frameworks or any parent theme, sometimes you might want to figure out whether a child theme is active or not. Here’s a quick function that’ll do exactly that:

function has_kids() {
	if (STYLESHEETPATH !== TEMPLATEPATH) return true;
	return false;
}

if ( has_kids() ) {
	// do stuff
}

This function works whether you call it from a child theme or parent.

2 Comments

  1. April 9th, 2009 at 12:06 pm | Permalink

    That’s a cool little snippet of code. I’m not sure what I’d do with it yet, but it’s good to bookmark away for later.

  2. Kel's Avatar Kel
    April 13th, 2009 at 9:28 am | Permalink

    On the same path… If you have a child theme (I’ll use Ian Stewart’s pro/paid Thematic child theme called Power Blog, as the example) and want to customize that – what do you do? Currently we’re talking about customizing themes by using Child Themes. If I wanted to make mods to Power Blog, I’d have to change the child theme directly, thus negating some of the reasons for using a Child theme – like upgradability.

    Do we get to a day where we need grandchildren themes? I think your code might be the start of a way to “group” the family theme files together.

Additional comments powered by BackType

About Ptah

I’m a 21 year old web developer, entrepreneur, and founder of Design by Craftsmen, web creative studio specializing in custom WordPress solutions. Get to know me.

Twitter