Child themes for WordPress: 4 Great Reasons to Use One

If you are a new WordPress developer, you might not see the value in creating your own child theme. You may be thinking to yourself, “child theme? But my theme does everything I need it to do! Why go through the extra effort?” Well, the truth is that if you are serious about making real customizations, even if it’s just CSS, you would benefit from creating a child theme.

You can learn all about parent themes and child themes directly from WordPress’s own documentation.

Having a child theme in WordPress is important for several reasons:

  1. Preserving customizations
  2. Safe updates
  3. Ease of customization
  4. Better organization

Overall, using a child theme is a best practice in WordPress development, as it helps ensure that your site is secure, functional, and easy to customize.

Why you should create a child theme in WordPress

Preserving Customizations

If you modify the code or styling of a WordPress theme directly, those changes will be lost when the theme is updated. However, a child theme inherits all of the functionality of its parent theme, and any changes you make to the child theme will be preserved even when the parent theme is updated.

Safe Updates

By using a child theme, you can safely update the parent theme without losing any customizations you’ve made. This is important because theme updates often include important security and bug fixes.

Ease of Customization

A child theme allows you to easily customize the appearance and functionality of a WordPress theme without having to write everything from scratch. This can save you time and effort and make it easier to create a site that looks and works exactly the way you want it to.

Better Organization

A child theme allows you to keep your customizations separate from the original theme’s files, making it easier to manage and keep track of your changes.

How to create a child theme in WordPress

To create a child theme in WordPress, you’ll need to follow these steps:

Create a new folder for your child theme

Create a new folder in your wp-content/themes directory and name it something that makes it clear that it’s a child theme (e.g. twentytwenty-child if your parent theme is Twenty Twenty). I am using the Divi theme, so I am going to use Divi-child.

Create a new style sheet

Inside your child theme folder, create a new file called style.css. In this file, you’ll need to add the following code at the top:

Theme Name: My Child Theme
Template: parent-theme-folder-name

Replace My Child Theme with the name of your child theme, and parent-theme-folder-name with the name of the folder for your parent theme.

Enqueue the parent theme’s style sheet

In the same style.css file, add the following code:

Theme Name: My Child Theme
Template: parent-theme-folder-name

/* Import parent theme stylesheet */
@import url('../parent-theme-folder-name/style.css');

In my case, I am creating a child theme using Divi by Elegant Themes as a template. You can read more about Divi in my article detailing why it is the best theme there is, in my experience. This will import the parent theme’s style sheet into your child theme.

child theme CSS file

Activate the child theme

Log in to your WordPress dashboard and go to Appearance > Themes. You should see your new child theme listed there. Click on “Activate” to activate it.

At this point, you can begin making customizations to your child theme’s files without affecting the original files of the parent theme. Any changes you make will be preserved even when the parent theme is updated.

Note that you can also add new files to your child theme, such as a functions.php file for adding custom functionality. Just be sure to include the Template header in your style.css file so that WordPress knows that it’s a child theme.

If you need help creating your own child theme in WordPress, feel free to reach out to me! I’m glad to help people learn how to build websites online.

Share this story, choose your platform!

Avatar photo
Gil Joseph Klein is a web developer and software engineer with over 13 years of experience building websites, developing application user interfaces, and using data science in business analysis. He is also a film score composer with credits on IMDB and is passionate about music.