Child Theme Wizard – Version 1.1 released

wizard

I’ve released a new version of my popular Child Theme Wizard plugin today. Everything remains the same, except for one thing: the parent theme is no longer loaded via CSS, it’s now being loaded via PHP. Let me explain why.

When I wrote this little tool in 2014, the best practice to create a child theme was to load the parent’s style sheet via CSS. This was done with an @import statement, like this:

@import url("parent-theme/style.css");

While this approach works just fine, this is no longer regarded as the best approach to the puzzle. That’s because the parent theme’s full path is hard coded into your child theme, and should the parent theme ever change it’s folder name, your child theme would stop working.

There’s a better way to get the same thing done by loading the parent style sheet via PHP in the functions.php file. Here’s how it’s done:

function theme_enqueue_styles() {

    $parent_style = 'parent-style';

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style )
    );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

So that’s what the update does: switch from the older way of loading the parent theme to the new one. There. Keeping up with the times and all 🙂

Download Child Theme Wizard

You can download the plugin from the official WordPress Plugin repository, or take a look at the source code on GitHub. Enjoy!





Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.