What is a child theme?

Have you ever wished you could tweak a few things in your WordPress site’s theme? If so, it would only make sense that you can make changes directly to your theme’s code, right? Well, not exactly — and this is where a child theme comes into play.

A child theme is a modified version of an existing theme. It’s installed as a separate theme, but it references the existing theme (known as a “parent” theme) in its code and requires it to work.

What is a child theme and why is it useful?

If you make changes directly to the code of a theme, those changes can be erased when the theme is updated because the theme overwrites any files that are changed in an update. For this reason, making changes directly to a theme is unwise. This is where child themes come into play.

A child theme essentially tells WordPress to use the parent theme unless a part of the theme is specified in the child theme. For example, if you wanted to change the footer of a theme, you could create a child theme with an updated footer file. This child theme would tell WordPress to use the parent theme except for the footer, because the child theme has its own footer file. This way, when the parent theme is updated, the updates don’t change the custom footer file created in the child theme.

How a child theme works

Every theme provides WordPress with basic information in the top of the theme’s style.css file, placed at the top in comment tags (between /* and */). If you’re creating a child theme, add one line in this section that says Template: followed by the name of the parent theme. Note: It’s important to be familiar with CSS and PHP to create a child theme.

If you want to customize any other files in the theme, copy that file into the child theme and make appropriate changes. If the file exists in the child theme, it will load that file into the theme. Any missing files are loaded from the parent theme. One exception is the functions.php file — this file is loaded from the parent theme and any code in the child theme’s file is appended to the parent theme’s file.

How to install a child theme

Child themes are installed just like regular themes. In your WordPress dashboard, go to Appearance > Themes and click the Add New button at the top. Upload the theme as a .zip file. In order for a child theme to work, the parent theme specified in the Template line of style.css must also be installed (it must also be spelled the same way as it is specified in style.css). When a child theme is active, WordPress will disable the ability to delete the parent theme.

If you’d like to make changes to your theme but you’re not familiar enough with CSS and PHP to make the appropriate changes, we can help! Contact us to get started.