Why Create A Child Theme In WordPress?
If your theme can be updated, you should create a child theme whenever you want to make edits to the theme. This way when an update happens you don’t lose all of your custom code.
How to Create A Child Theme In WordPress
- Navigate to wp-content/themes/
- Create a new folder named Parent Theme – Child (where parent theme is the actual name of your parent theme)
- Enter your newly created folder
- Create a file called style.css
- Add metadata in this style.css file like below
(Replace “Parent Theme” with the name of your parent theme and “parent-theme-folder” with the actual folder name of your parent theme)
/**
* Theme Name: Your Parent Theme Child
* Template: parent-theme-folder
*/
- Hit Save
- Activate your new child theme from the wordpress backend in Appearance -> Themes menu.
Custom Content and Missing Parent Theme Styling
If you have any custom content (like from another one of my videos) in your theme already that you did not put in a child theme, move it over now. In this video, I recreated functions.php and added my custom content there. Copy the file from your parent theme folder to the child theme folder. Any file in the child theme will override the parent theme’s file.
Also, if you create a child theme and you lose your parent theme’s styling, make sure to enqueue your parent theme’s style in functions.php in the child theme.