This tutorial will show you how to create a child theme for your WordPress theme.
A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme.
Using the child theme is the recommended way of modifying an existing theme.
A child theme consists of at least one directory (the child theme directory) and two files (style.css and functions.php).
- Please, download the child theme sample, it already has all the needed files included.
- Unzip the downloaded package on your computer. You will need to make modifications in style.css and functions.php files.
- In the style.css file, you should modify 2 lines: Template and Text Domain. All the rest, like Theme Name, Author, Description can be left as it is, but also you can adjust the info according to your preferences.In the file from a package you downloaded these lines have the following content:In the file from a package you downloaded these lines have the following content:
You should provide your parent theme folder name instead of “parent_theme_folder_name_here”, for example, mohican.
In the example-child (Text Domain) “example” should be replaced with the parent theme folder name too. This would be mohican-child in our case.
- Open functions.php file for editing. You need to edit line #9:
- example should again be replaced with the name of your parent theme folder name, e.g:
- You will also need to edit the following function:
Replace all instances of “example” with the parent theme folder name, e.g. mohican:
- After making these changes, create a .zip package that contains your child theme folder (it can have your own child theme name instead of child-example).
- Install a new child theme via Appearance > Themes > Add new from WordPress dashboard and activate it.
In case all the steps are completed correctly you should see a message:
Unpacking the package…
Installing the theme…
This theme requires a parent theme.
Checking if it is installed…
The parent theme, parent_theme_folder_name_here, is currently installed.
Theme installed successfully.