With everyone around the world self-isolating, itβs important to make sure your site is as optimized as possible. Now more than ever, you want people to come to the site and stick around.
With WordPress, you can easily customize any aspect of your website, including the theme you use. However, tweaking its code directly can be risky, and you may lose your changes when you update it. Using a child theme, you run none of those risks.
A child theme is basically a copy of its βparentβ. You can set one up rather quickly and with this approach, you can edit your theme safely. Plus, you wonβt lose any of the changes youβve made, even during an update.
In this article, weβll dig deeper into why you should be using child themes for custom development. Then weβll show you how to create one in a few simple steps. Letβs get to work!
The Benefits of Using a Child Theme
A child theme is a template that imports the style of its parent. For all practical purposes, itβs a copy of the original, only you can make changes to it without affecting the latter.
Letβs say, for example, you want to modify your themeβs functions.php file to add a new feature. You dig into its code, make the necessary changes, and everything works perfectly.
Soon after, however, a new version of your theme is released. Naturally, you jump at the chance to install it since itβs always wise to update your WordPress components.
However, updating the theme overwrites the changes youβve made to its core files. The new feature you added to functions.php is gone and you have to start all over again.
Alternatively, you could create a child theme and edit its functions.php file instead. When the update is released, youβll apply it to the parent theme and your changes will be preserved.
Not only does it make for a much cleaner development process, but itβs also safer for testing new functionalities. After all, if you break anything, you can simply deactivate the child theme and start over.
How to Create and Customize a Child Theme (In 5 Steps)
Creating a child theme is simple, but there are a few steps involved. To follow along, youβll need a File Transfer Protocol (FTP) client such as FileZilla. Once youβve installed it and have your credentials in hand, youβre just five steps away.
Step 1: Create a Folder for Your Child Theme
Every theme you install in WordPress sets up its own folder on your server, which contains all the files it needs to work. You can find these directories by using FTP to navigate to wp-content/themes:

One of these folders belongs to your active theme. Take note of its name, then create a new directory. For this tutorial, weβve called ours twentytwenty-child since weβre going to be using Twenty Twenty as the parent theme:

You can follow the steps in this post using any parent theme you want. The name you set for its child doesnβt make any technical difference either. However, it helps if itβs something thatβs easy to identify.
Step 2: Set Up a style.css File
Next, weβre going to set up the file that WordPress uses to recognize new themes. Itβs called style.css and as the name implies, it contains all the CSS styles for your site.
For now, create a new file within your child theme directory and name it style.css. Once itβs ready, right-click on it and select View/Edit:

This will open the file with your local text editor. Right now, it should be empty. Copy the following code and paste it within your child themeβs style.css file, then customize the placeholders:
/* Theme Name: Twenty Twenty Child Theme URL: http://yourdomain.com Description: My first child theme, I'm so proud. Theme Author: John Doe Author URL: http://yourdomain.com Template: twentytwenty Version: 1.0.0 Text Domain: twentytwenty-child */
Replace every instance of the parent themeβs name with the one youβre using. Youβll also want to include your own domain and information, then save the changes to style.css and close it.
Step 3: Import the Parent Themeβs Styles and Scripts
For your child theme to retain its parentβs style and functionality, you need to import all the code that makes it work. You can do this through a process called βenqueueingβ.
To get started, set up a new file called functions.php within your child themeβs directory. Then open it and paste the following code within:
<?php add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' ); function enqueue_parent_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' ); } ?>
Save the changes to functions.php. Youβll notice that this code doesnβt specify anything about the parent theme. Thatβs because we already defined the template it needs to import when we edited the style.css file.
Hereβs how your child theme folder should look now:

Technically, you could achieve the same result by copying and pasting the contents of the parent themeβs functions.php file. However, with that approach, youβd need to modify the codebase manually every time an update was released.
By enqueueing the parent themeβs styles and scripts, you bypass that issue. Now, your child theme should be working. All thatβs left is to customize and activate it.
Step 4: Customize Your Child Theme
Making changes to your child theme works pretty much the same as editing any other. For example, you can customize your siteβs style by tweaking its style.css file. All you have to do is add any new CSS code you want below the theme description you set up earlier:

Keep in mind β any changes you make will override conflicting styles or functions from the parent theme. That goes for style.css, functions.php, and any other files you set up.
If this is your first rodeo when it comes to theme customization, we recommend you check out our full guide on the subject. We also have tutorials on CSS basics, so take a look at it if youβre not comfortable with stylesheets yet.
Step 5: Activate and Maintain Your Child Theme
If you go to your dashboard and navigate to Appearance > Themes, you should see your child theme listed:

Activating your child theme works just like any other. After you click on the Activate button, go ahead and check out your homepage:

In a nutshell, if you were previously using the parent theme, your site should look exactly the same as it did before. Until you start making customizations, you wonβt notice a difference between the two.
Itβs important to note that while youβre using a child theme, you canβt delete its parent files. Otherwise, it wonβt be able to import the styles or functions it needs to work properly.
Likewise, youβll want to check for any updates available for the parent theme as usual. Just because youβre using a child theme, doesnβt mean youβre exempt from security best practices.
Conclusion
If youβre going to add new functions to your WordPress theme, the safest way to do so is through a child theme. That goes double if youβre working on a client website.
Fortunately, setting up a child theme is relatively simple. Hereβs how the process works:
- Create a folder for your child theme.
- Set up a styles.css file.
- Import the parent themeβs styles and scripts.
- Customize your child theme.
- Activate and maintain your child theme.
Do you have any questions about how to use a WordPress child theme? Letβs go over them in the comments section below!