You love your WordPress theme, but there are a few things about it that could use some tweaking.

Maybe you’d like to try using a fancy new typeface from the Google Fonts library, change the styling of your blockquotes in a post, or change the wording of your post meta under the headline.

Simple tweaks like these are usually a matter of copying and pasting a code snippet in the right place, which you can definitely handle.

The problem comes when your theme suddenly has an update available.

You know you need to update your theme to protect your website from vulnerabilities and have access to the latest features…

…But what will happen to all those little changes you made?

Unfortunately, if you’ve edited your theme, all your changes will be lost when a new version is released.

While this used to be a huge problem in the early days of WordPress, there’s now a built-in system that lets you make whatever changes you need to separately from your theme files, keeping them safe when you update your theme to the latest version: child themes.

If you’ve been using WordPress for a while, you’ve probably heard of child themes before, and for good reason: they’re an incredibly useful feature.

They’re also pretty easy to create. If you can copy and paste a code snippet to tweak your theme, you have the skills required to create a child theme.

In this post, we’ll go over all you need to know about child themes and how to create your own, step by step.

What exactly are child themes?

In a nutshell, a child theme is a WordPress theme that inherits all its functions and styles from a parent theme.

Here’s how it works:

Any WordPress theme at all can be used as a parent theme. A child theme requires a parent theme, and both the child and parent theme must be installed on your WordPress site. When you activate the child theme, it tells WordPress to use the parent theme for all the required theme files (functions, styles, page templates, etc.).

But any additional code or files that you add to the child theme will be used instead of their corresponding parent theme files. (You can read more on exactly how that works in the tutorial below.)

The only thing required to create a child theme is two files: a style.css file, and a functions.php file.

These are basic files that are required with every WordPress theme. The style.css file determines the look of the theme using CSS code, while the functions.php file is used to change or add functionality to the WordPress core using PHP code. You can read more about CSS and the functions.php file in the WordPress Codex.

The child theme’s style.css and functions.php files are placed in a separate theme directory specifically created for your child theme. The child theme’s functions.php file is used to tell WordPress to load the original style.css from the parent theme, duplicating its look.

The child theme’s style.css file points WordPress back to the parent theme for all the other required files, including the parents theme’s original functions.php file, which is added onto the new functions.php in the child theme.

While those two files are the only ones required to create a child theme, you can actually add other files as well in order to customize your child theme further. Any file that’s included in your child theme directory will overwrite any corresponding file in the parent theme.

So if you wanted to make changes to a page template, for example, you could copy the file from your parent theme and place the copy in the child theme directory, and then make your desired changes to the file in the child theme. WordPress would then use that file instead of the original one in the parent theme directory.

It sounds a little complicated, but the end result is a theme that references the original parent theme, which you can add your own code to in order to customize it. When the parent theme is updated, your child theme (and any customizations you’ve made) remains unaffected.

What’s so great about child themes?

Why go through the trouble of creating a child theme when you can just change or add things to your main theme?

Well, using a child theme to make changes to your theme has a lot of advantages and benefits:

  • You can update the parent theme to the latest version at any time, and your child theme will remain untouched.
  • If something goes wrong and your site goes down, you can use the parent theme as a quick and easy fallback.
  • Making changes to a child theme can be faster and easier, since you only have a few files to deal with, instead of digging around in all the parent theme’s files.
  • Creating a child theme is also a great way for beginners to learn a bit about how WordPress works, and an excellent first step before creating your own theme.

Convinced? Here’s how you can quickly create your own child theme.

How to create a basic WordPress child theme

In this tutorial, we’ll create a child theme of the default WordPress Twenty Fifteen theme.

Step 1: Locate your parent theme directory

First you’ll need to find where your parent theme is located, and make note of the directory name so you can reference it later on.

There are a few different ways to do this, but I’ll show you one way that you can follow in your browser, without using any outside programs.

In this step, instead of using your WordPress dashboard, navigate to your web host and log in to your hosting dashboard. The most commonly used dashboard is cPanel, but depending on what web host you have, the following screenshots may look slightly different for you.

Once you’ve logged in, look for an icon labeled “File Manager.” Here’s how it looks using Bluehost:

CPanel

Your File Manager icon may not be in exactly the same place, but you can use the search box in the left sidebar to find it if you don’t see it right away.

The File Manager will open in a new tab. In the left navigation panel, find and open the folder for your website, where you installed WordPress. There should be a folder inside called “wp-content.” Inside that folder, open the folder named “themes.”

Inside, you’ll see all your installed themes:

File Manager

Find the directory your chosen parent theme directory is in, and make note of the exact folder name. In this tutorial, we’re using Twenty Fifteen, which is in a directory named “twentyfifteen.”

Step 2: Create your child theme directory

Inside your themes folder, we’ll go ahead and create a new directory for a child theme for the default WordPress theme, Twenty Fifteen.

Click the “New Folder” icon from the top menu, and create a folder called “twentyfifteen-child.”

(You can name a child theme whatever you like, but be sure to make note of the exact directory name for later reference.)

Create Folder

Go ahead and open up your new folder.

Step 3: Create the style.css file

Next we’ll create our new style.css and functions.php files inside the “twentyfifteen-child” directory.

Click the “New File” icon at the top menu, and create a file named style.css.

Now we’re going to open up that file and add some code. You can do that by right clicking on the file and clicking “Edit” (the third option down).

Edit File

You’ll see a completely blank document open up in a new tab.

Now, cut and paste this code into the document:


/*

 Theme Name:   Twenty Fifteen Child

 Theme URI:    http://example.com/twentyfifteen-child/

 Description:  Twenty Fifteen Child Theme

 Author:       Your name

 Author URI:   http://example.com

 Template:     twentyfifteen

 Version:      1.0.0

 License:      GNU General Public License v2 or later

 License URI:  http://www.gnu.org/licenses/gpl-2.0.html

 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready

 Text Domain:  twentyfifteen-child

*/

You’ll need to make some changes for your site:

  • Theme URI: Replace “example.com” with your website URL where you have WordPress installed.
  • Author: Add your name here as the child theme author.
  • Author URI: Change this to your main website (for example, www.your-name.com).

You can also change the description, version, licensing details, and tags as appropriate, since they don’t affect the function of the theme.

The bit that makes this file work is the “Template” line, which points to the parent theme. The value here must match the parent theme’s file directory exactly.

Once you’ve made your edits, go ahead and click the “Save Changes” button in the upper right-hand corner, then click the “Close” button right next to it to go back to the File Manager.

Step 4: Create the functions.php file

Next, we’ll create the functions.php file. Click the “New File” icon in the top menu and name your new file functions.php.

Go ahead and open up your new functions.php file by right-clicking on it and selecting “Edit.”

Functions Edit

You’ll be greeted with another blank screen. Here you can copy and paste the following code:


<?php

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

function theme_enqueue_styles() {

    wp_enqueue_style( 'parent-style', get_template_directory_uri() . 'http://wpsuperstars.adamconnell1.netdna-cdn.com/style.css' );

}

This code is what tells WordPress to load the style.css document from the parent theme.

Click on the “Save Changes” button in the upper right-hand corner, then click “Close.”

We’ll be switching over to your WordPress dashboard in the next step, but you can keep the File Manager open, since we’ll be going back to it in the following step.

Step 5: Test your child theme

In a new tab, log in to your WordPress dashboard, and navigate to Appearance > Themes.

You should see your new child theme right next to the parent theme:

Activate

You can go ahead and activate it, then check your website to make sure it looks the same as the parent theme.

(If it doesn’t, go to the Troubleshooting section below to find out about common errors and how to fix them.)

Step 6: Make your adjustments

Your child theme works, but we’re not done yet. You made your child theme for a reason: to make changes to the parent theme, not just duplicate it.

Go back to the tab where you have your File Manager open. Here you can open your style.css file to add or change your CSS files, or your functions.php file to add PHP snippets.

(You can also edit existing files directly from the WordPress dashboard under Appearance > Editor, but you can’t add new files that way.)

Remember that the functions.php is loaded in addition to the parent theme’s functions.php file, so there’s no need to copy and paste the functions from the parent theme’s functions.php file — they’re already included in your child theme.

You can also make changes to page templates and other files by locating them in the parent theme directory, and creating a copy in the new child theme directory. Then, make whatever changes you like to the new file in the child theme, but keep the file name the same. WordPress will now use that file instead of the corresponding one in the parent theme directory.

That’s it! Your child theme is all set up and ready to go.

Troubleshooting your child theme

If you’re getting error messages or your child theme is making your site look weird, here are some common issues to look out for.

Error messages in your WordPress dashboard

You’ve created your child theme directory, but it’s not showing up in your WordPress dashboard. Instead, it’s telling you that you have a broken theme. What’s up?

This is usually caused by a missing file, or missing information within the file. Double check the new style.css and functions.php files you created in the File Manager, and make sure all the information was copied, pasted, and edited correctly.

The child theme activates, but doesn’t look right

Maybe you were able to activate your child theme, but it doesn’t look anything like your parent them? That’s probably because the stylesheets from the parent theme didn’t load correctly.

First, double check the functions.php file you created to make sure the code was copied and pasted correctly, and that nothing is missing.

If it’s still not working, it could be because you’re trying to create a child theme for a parent theme that uses multiple stylesheets. Some themes use not only style.css to store their styles, but other CSS files as well. Check out the WordPress codex for some tips on how to make sure you’re loading all the stylesheets from your parent theme.

Still having trouble?

If you’re still having problems getting your child theme to work, try contacting the developers for your parent theme, or posting in the WordPress support forums for help.

Wrapping up

Using a child theme is a great way to avoid losing theme customizations.

Nothing is worse than updating your theme, only to remember that you edited a few lines of code in a random file and something doesn’t look right anymore.

Put together your child theme and get peace of mind.

Posted by KeriLynn Engel

KeriLynn Engel is a copywriter & content marketing strategist. Keri loves working with B2B & B2C businesses to plan and create high-quality content that attracts and converts their target audience. When not writing, you can find her reading speculative fiction, watching Star Trek, or playing Telemann flute fantasias at a local open mic.