WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My parent theme has a file with a class that defines ads for that specific theme. It is required in functions.php. My child theme needs a duplicate file with different ad parameters so I would like to not include the parent theme's file.

Is there an easy way to ensure the parent theme file will not be required in the child theme?

share|improve this question
up vote 0 down vote accepted

You could use is_child_theme() in the parent theme's functions.php file:

if ( ! is_child_theme() ) {
    require( 'path/to/ads/file.php' );


If you don't want to edit the parent theme -- for instance, so that any updates to the parent theme won't overwrite what you've done -- you could do something like this in the child theme's functions.php file:

global $ads_class; // whatever your ads class is named
if ( 
    is_child_theme() && 
      class_exists( 'Ads_Class' ) && 
      'Ads_Class' == get_class( $ads_class) 
   ) {
share|improve this answer

Your Answer


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.