Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in the functions.php of a parent theme, I would like to check for wheter the theme is being run directly, or it is run via a child theme.

Is there a conventional way of doing this? I cant find the is_childtheme() function I would have liked to have found.. so whats the best way? Check for theme name and compare it to parent theme's maybe? how can this be done?

share|improve this question
    
Now I simply check if get_current_theme() != 'ParentThemeName' –  mikkelbreum Apr 15 '11 at 21:34
add comment

2 Answers 2

up vote 5 down vote accepted

As One Trick Pony said, there's a dedicated function (since WP 3.0):

is_child_theme()

share|improve this answer
add comment

WordPress Core does it like this (at least, at one point):

if( TEMPLATEPATH !== STYLESHEETPATH )
  // We have a child theme active
share|improve this answer
    
I think it's available in 3.1 as is_child_theme() –  onetrickpony Apr 15 '11 at 22:10
    
Same thing I was going to suggest: compare get_stylesheet_directory_uri() and get_template_directory_uri(). –  Chip Bennett Apr 15 '11 at 23:34
    
I was going to suggest something similar... get_bloginfo( 'template_directory' ) == get_bloginfo( 'stylesheet_directory' ) ... :) +1 –  t31os Apr 16 '11 at 8:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.