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. Mr. Versluis,

    Thank you for creating the child theme wizard. I watched your video and read the documentation associated with it, but I still don’t understand what the Child Theme URL field is referring to. Could you please explain further? Thank you,warm regards,

    John M.

  2. Hi John, the URL field is a metadata field. If you take a look at your installed themes, you’ll find that the ones made by WordPress link to automattic.com – that’s the URL you put in there, one that links to your theme (say a Github page, or where or where others can download your theme). Needless to say it’s optional.

  3. Hello mr Jay Versluis,

    The plugin made a subdir, copied the style.css and a start for the function.php. So far so good.
    [A] I have lot of CSS made for shadow buttons and so on. But were not executed. Made the extensions by hand in the ‘normal’ style.css and it’s working. ( but I have still a few websites to go.

    [B] I made an enhancement to the footer.php, can I arrange this by coping the footer.php to the Child-directory ?

  4. Hi there! As for A, I have no idea. Anything in the child theme’s style.css should be pulled in. If it doesn’t work, I don’t know why. And B, yes indeed – you’re absolutely right: copy the footer.php (or any other amended file) into the child theme’s directory, and WordPress will load that instead of the original. As a rule of thumb, if a file is present in the child theme, it will be loaded instead of the original.

Leave a Comment!

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