Soliloquy Blog

WordPress slider tips, Tutorials and Resources.
WordPress child theme

How to Create a WordPress Child Theme

by [email protected] on March 15, 2018

Child themes are an important WordPress functionality–vital for some users and helpful to know about regardless. What is it, how do you create them, and when should you use them? This mini-guide has all the answers.

Why Use Child Themes?

A child theme is a sub-theme that has the functionality of a “parent” theme but doesn’t make changes to this parent when modified. Why is this useful? For theme developers working with a framework like Genesis, child themes are what you base your work around.

But users can make use of them as well. For those who love delving into the theme’s code and changing it to suit their needs, unless you use child themes, all your work is lost when you update. Also, if you make a mistake that messes up your website, it’s much easier to revert it when those changes are made on the child theme.

When not to use one? If a theme comes with built-in customization options, and you only touch those, they won’t be affected by an update. But if you want to make any changes to the core files, you should be using a child theme. Plain and simple.

Step-By-Step Guide

If you just downloaded a child for a parent theme you already own, all you need to do is go to your admin page, then Appearance > Themes and activate it. From there, you can work with it normally.

If you’re trying to create a child theme yourself, you have a bit more work ahead of you. First, go to the theme directory (“wp-content/themes”) in your WordPress installation. Create a folder for your new theme. You can name it anything, but “themename-child” is a good idea.

In this folder, create a text file named style.css. This is how WordPress recognizes it as a theme. Within the text file, create the stylesheet header by pasting and filling out this code at the top:

 Theme Name:

“Template” is the folder name of the parent theme, and it is case sensitive. If your theme will be uploaded to the repository, see this link for information on how to customize your style.css header.

Activate your child theme by going to Appearance > Themes. If your website looks like a mess, you’re doing everything correctly. Because you created a custom style.css, we have to make your website read the parent’s style.css as it’s being overridden.

Go back and create a text file named functions.php. Add this code:

 add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
 function enqueue_parent_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );

Your website should be fixed. You are now ready to modify your new child theme.

Use a Plugin

If all this sounds like a huge hassle, or you encounter difficulties while trying to set up a child theme manually, you should use a plugin instead. There are many helpful plugins out there, including Child Theme Configurator and Child Theme Creator.

Each has its own instructions, some more difficult to follow than others, but it’s far easier than fiddling with the code yourself.

Optimizing Theme Development

If you’re ready to develop themes from a framework or tweak your personal theme, make sure you understand how to set up a child theme. You never know what could happen, and you should always have a parent to fall back on in case of updates or mistakes.

If you never modify the files of a theme, you should be fine to go without or to use a CSS plugin for small tweaks. But keep this in mind when you’re ready to go into the code and really make a theme your own. And remember: no matter what route you take, always back up your site! 

Have you ever created a child theme? What was the process like for you? Feel free to share below. And as always, follow us on Twitter and Facebook to keep up to date with even more of our content.

Leave a Reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.