How to Use Child Themes in WordPress


Sometimes a perfectly good WordPress theme comes short in a specific functionality. It is possible to improve the theme by tinkering with its css and php files directly. The disadvantage of this approach is that whenever the tweaked theme receives an important security update from its authors, all the tweaks and changes are permanently lost.

Hardcore tweakers might backup the files they have tweaked and apply the same tweaks to the theme’s updated files, but obviously there must be a better way, a less time-consuming way. And there is.

Changing a theme’s files directly makes sense only in cases when a theme is clearly abandoned for years and is not going to get an update ever again.

Creating a Child Theme

But if you are using a live theme, then it is best to create a child theme.

A child theme is a copy of your original active theme. It is better to make changes to a child theme rather than to the original, so-called parent theme. When the parent theme gets updated, you will not lose the changes you have already implemented, because the changes are saved within the child theme.

The easiest way to create a child theme is to install the One-Click Child Theme WordPress plugin.

This plugin enables you to create a child theme to your active theme by clicking WordPress Dashboard > Appearance > Child Theme.


Create a Child Theme

You will be then required to give a name to your new child theme — I recommend Theme Name Child, where Theme Name is the name of your existing theme. Then click on the Create Child button and your child theme will be created and activated.

Adding Files to the Child Theme

By default, your new child theme will only contain the style.css and rtl.css files and inherit everything else from the parent theme. To add php template files to the child theme, you need to log onto your FTP server and copy them from the parent theme’s folder into the child theme’s folder.

I recommend using the free and awesome WinSCP for this kind of work.

All you need are the access information to your FTP server — a file protocol, a host name, a user name, and a password. Your web hosting company must have provided you with these in the beginning of your cooperation.

If you have these access information, you can install and run WinSCP. Inputting the access information is very intuitive. Once you are connected to the FTP server, go to your WordPress installation’s /wp-content/themes folder.

Select and enter your active theme’s folder. Select the files you wish to change. You can select multiple files by holding down the Ctrl or the Shift key while clicking on the files. When all the necessary files are selected, press Shift+F5 to duplicate them to the child theme’s folder on the server.


FTP Duplicate Files

Once you are done duplicating all the necessary files to the child theme’s folder, go back to WordPress Dashboard > Appearance > Editor. Now you will be able to edit all the files you have just duplicated right within WordPress’ Theme Editor.

All changes you make to the child theme’s files will be preserved even if the parent theme gets updated. The child theme will use all those parent theme files that you have not duplicated into the child theme’s folder.

You don’t need to duplicate your parent theme’s functions.php file or if you already did then just delete the content of functions.php in your child theme and put there this code:

WordPress will automatically load all functions first from the child theme’s functions.php file and then from the parent theme’s functions.php file. So having the same code twice would load all functions twice.

Only add new functions to the child theme’s functions.php file, otherwise the above code suffices.

I hope that you found this tutorial helpful. If you have any questions or uncertainties regarding creating and using child themes, please, don’t hesitate to tell me in the comments below.

To learn more about child themes, read up on them in the WordPress Codex.

Liked this post?

Subscribe to our newsletter to receive early notification of new posts and deals:
[mc4wp_form id=”45″]

Next Post »« Previous Post