What are WordPress child themes?
Child themes are a simple way for you to modify WordPress themes, and keep track of all your changes. With child themes you can make all of the same modifications as you would to the parent theme, but you do all of this in a separate child theme area. This allows you to update the parent theme whenever you want and still keep all of the modifications you have made in your child theme area.
There are several different levels of modifications you can make to a child theme. If you are careful with how you make your child theme modifications, you will be able to update the parent theme, and have all your theme modifications automatically transfer to the updated theme with very little effort from you.
Here we discuss how to create child themes. Once you create a child theme, you can easily –
Create a Child Theme
To create a WordPress child theme all you need to do is create a new directory for your child theme in your blog wp-content/themes directory. Name the directory based on your child theme name, as well as the parent theme name so that you can easily keep track of all your WordPress themes.
For example, one of my blog child themes is called dogs-child-shiba. Dogs is the name of my child theme, child indicates that it is a child theme, and shiba is the name of the parent WordPress theme. This allows me to easily identify all of my child themes, and to quickly see what their parent themes are.
After creating a new child theme directory, create a style.css file within it, and enter the code below into your new style.css file.
/* Theme Name: dogs-shiba-child Theme URI: http://www.shibashake.com/wordpress-theme Description: Child theme for Shiba. Author: ShibaShake Author URI: http://www.shibashake.com Template: shiba Version: 1.0 Tags: child theme */ @import url("../shiba/style.css");
The code above gives you an example child theme definition for the Shiba parent theme. To create your own child theme you want to replace each of the elements with your own child theme information.
Line 2 – Replace with the name of your child theme. (required)
Line 3 – Replace with the name of your blog homepage. (optional)
Line 4 – Replace with a description of your child theme. (optional)
Line 5 – Replace with your name. (optional)
Line 6 – Replace with your website. (optional)
Line 8 – Replace with the directory name of the parent template you are using. (required)
Line 9 – Replace with your child theme version number. You can increase your version number as you make new changes to your child theme.
Line 10 – Tags you want to associated with your child theme. This is important if you want to distribute your child theme for public use. Otherwise, you can use it to help yourself keep track of the features added to your child theme, e.g. widget ready, light, blue.
Line 13 – Includes the parent theme styles into your blog. Replace the parent theme directory name with the parent theme you are using. For example, if you are using the WordPress Classic theme as your parent theme, replace the statement with
@import url("../classic/style.css");
We use the directory name classic here because the WordPress Classic theme is located in the classic directory of your WordPress blog. If you go to Appearance >> Themes in your WordPress blog dashboard, you should be able the see the directory name for all your installed themes.
For example, if you look at the WordPress Classic theme, it should contain the following information –
All of this theme’s files are located in
/themes/classic
This means that the theme directory is called classic. Each theme will have a different theme directory. The WordPress Default theme, for example, is located in the
default
theme directory, and my Shiba WordPress theme is located in the
shiba
theme directory.
You’re Done!
And there you have it – your very own child theme. You can apply child themes the same way you apply regular themes on WordPress. Just go to Appearance >> Themes and click on the Activate link right below your child theme.
Once you have a child theme, you can start adding new design styles to your blog or override existing styles that may not suit you. You can also create dynamic styles.