Why do we need Child Themes? If you want to modify a theme and you don’t want to lose your modifications then you have to create a Child Theme. Child Theme allows you to update the Parent Theme without impacting your modifications. So, if you want to change something in your current theme then you should do it through a child theme.
Simple example:
Let’s say you’ve changed a background color in your Twentytwelve Theme by modifying
wp-content/themes/twentytwelve/style.css
file. But when Twentytwelve Theme is updated then you would lose your modifications.
Don’t worry if you have never made a WordPress Child Theme before. Creating your own Child Theme is actually very easy. First, you have to create a new folder under the themes folder ( wp-content/themes
). Then create a new CSS file in the child theme folder and name it style.css. Your next step is to add some information to that style.css file so WordPress knows that this is a child theme.
/*
Theme Name: Your Child Theme
Theme URI: http: //your-website.com/
Description: This is a custom child theme.
Author: Your Name
Author URI: http: //your-website.com/
Template: parenttheme
Version: 0.1
*/
@import url("../parenttheme/style.css");
If you want to override Parent Theme template files then you have to make a copy of original template file and paste that copy to the Child Theme folder. The file should have the same file name as original template file and folder structure should be the same as in the Parent Theme.
When you are done with your Child Theme you have to activate it. Go to Appearance -> Themes in your WordPress admin area. Find your Child Theme and activate it!