A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes allow you to change certain design elements or features of your site without changing the parent theme directly. They are the recommended way of modifying an existing theme.
Using a Child Theme
The main reason to use a child theme is this: if you modify a parent theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
You might be thinking that you just won’t install theme updates in the future. However, what if an important security update or a critical bug fix is released for the theme? You will need to install these updates, so we recommend you to make your customizations in a child theme.
Creating a child theme can be a bit intimidating if you don’t know what to do. Lucky for you, we’ve created starter child themes for all of our themes. Getting started is as easy an uploading the child theme and activating it.
If you have downloaded the theme package from ThemeForest you will see a directory named “Child Theme”, inside of which you will find a .zip file. Simply upload it like you would have for a standard WordPress theme. The child theme will include a blank
functions.php that you can edit to fit your needs.
To get started:
- Download the child theme that works with your parent theme.
- Upload the child theme by visiting Appearance > Themes in your WordPress dashboard. Click Add New and upload the child theme zip file.
- Activate the child theme.
- Modify the child theme files to your needs. To edit the
functions.phpfiles you can visit Appearance > Editor in your WordPress dashboard..
Finally, your theme might also have been packaged with several already customized child themes. Feel free to use these child themes as a guide for creating your own child theme.
Now that you’ve activated your child theme, you’re ready to make your customizations. Custom styles go in your child theme’s
style.css file. Inside the
style.css file, you’ll see a line at the bottom that says this:
* Add your customizations below this line.
This is where you add your custom styles.
Customizing Template Files
Sometimes you need to do more than customizing styles. For example, you may want to change the text shown in the footer of your site. To do this, copy the
footer.php file from the parent theme into your child theme’s folder and edit the text in the new file. The new file will automatically take precedence over the parent theme file, and any changes you make in the new file will be saved when you update the parent theme in the future.
You can also customize templates within sub folders of the theme. In your theme there may be a
template-parts/ folder with various mini templates used throughout the theme. To customize a template file in a sub folder, you’ll want to copy that template file and place it in your child theme with the same path. For example, if you want to customize
template-parts/content.php, you’ll want to place that in
template-parts/content.php in your child theme.
functions.php file, see this guide from the WordPress Codex.