Child Theme Wizard – Version 1.1 released

- by

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!



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

9 thoughts on “Child Theme Wizard – Version 1.1 released”

  1. Hello, thanks for your answer.
    Regarding [B]
    if the theme author made also an enhancement in the footer.php, I’missing by copying the full file.
    What if I take this footer.php, just only my lines ….. or will it be completely overwritten ?

  2. You’ll have to copy the entire file over, WordPress will replace it completely. Partial amendments only work with style.css, all other files will be overwritten completely by the child theme.

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.