What Is A Child Theme?
As defined by WordPress codex, a child theme is s theme that “inherits the functionality and styling of another theme, called the parent theme.” A child theme allows you to make changes to your WordPress theme without breaking the parent theme’s functionality.
Steps To Setting Up A Child Theme
Here are the developer steps to creating a child theme, if you aren’t comfortable in working with code and FTP, click here to skip to the download link and non-developer guide to setting up a WordPress child theme.
A WordPress child theme requires 2 main files to work: style.css and functions.php.
You can setup a custom child theme by following the steps below:
- Login to your site via FTP or using a File Manager that your hosting provider may offer.
- Navigate to wp-content and select the themes directory.
- Once inside the themes directory, create a new folder with your child theme name, no spaces or underscores. Use dashes to separate the name for example my-child-theme
- Enter your child theme folder and create your style.css and functions.php file.
- Edit your style.css and functions.php with the code below.
style.css
The style.css file tells WordPress information about your theme, including what template it should inherit. The template would be the folder name of your parent theme.
/*
Theme Name: My Child Theme
Theme URI: https://yoohooplugins.com/wordpress-child-theme/
Description: This is a Child Theme Example
Author: Yoohoo Plugins
Author URI: https://yoohooplugins.com
Template: change-this
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-child-theme
*/
// Custom CSS goes after this line
functions.php
The functions.php file will handle all the technical logic of loading the inherited style from your parent theme. You do not need to change anything from the below code, you can copy and paste it into your child theme’s functions.php file.
Go to your WordPress Dashboard and to themes page, you should see your child theme listed, and you can activate it.
To make any custom changes to your theme, open up the child theme folder with cpanel/folder. If the file you want to customize from the parent theme is the header.php, copy the file from the parent theme and paste it in the child theme, here you can make changes to the header.php file and it won’t affect the file in the main theme, but your customization will be applied to your site.
Note: if the file you are customizing is in a folder in the parent theme, for example, the file is in a folder called templates, “templates/front-page.php”. You have to create a “templates” folder in your child theme, before copying the “front-page.php” file to the “templates” folder.
Using A WordPress Plugin To Create A Child Theme
There is a plugin called Child Theme Configurator that you may use to setup a WordPress child theme directly from your WordPress dashboard:
https://wordpress.org/plugins/child-theme-configurator/
This plugin has steps that you may work through to get your child theme setup.
Summary
After working through this guide, you should have been able to created a child theme for your WordPress site, or set one up from our zip example file or using the Child Theme Configurator plugin.
This is one step closer to making your WordPress environment more stable and follow good coding/setup practice. Almost every site I have setup makes use of a child theme, even if I haven’t added any custom code.
For more information about child themes, have a look at the WordPress developer’s handbook.
Please feel free to leave a comment, all questions are welcomed and encouraged. If you have any suggestions on improving this process or making it easier, please let us know so we may update this guide.
Photo by NordWood Themes on Unsplash