How to Create a WordPress Child Theme
Almost every WordPress theme can be used as a parent theme (or main theme) and allows for the creation of a child theme, or a subset of instructions, to override its files. This structure ensures that a child theme can selectively modify the layout, styling, and functionality of the parent theme without touching any of the code of the main, parent theme.
The reason you might want to create a child theme based on a parent theme is to keep the template features, functions, and styles of the parent intact so that when you upgrade it in the future, the upgrading doesn’t override any of the customizations or changes you made to the design of the child theme. You therefore maintain the integrity of the main theme while modifying the visual look using a child theme.
As do regular themes, a child theme needs to reside in a directory inside the /wp-content/themes directory. The first step to creating a child theme is to add the directory that will hold it. For this example, create a new directory called twentyeleven-child inside the /wp-content/themes directory.
To register the twentyeleven-child directory as a theme and to make it a child of the Twenty Eleven theme, create a style.css file and add the appropriate theme headers. To do so, type the following code into your favorite code or plain-text editor, such as Notepad for the PC or TextMate for the Mac, and save the file as style.css:
/* Theme Name: TwentyEleven Child Description: My fabulous child theme Author: Lisa Sabin-Wilson Version: 1.0 Template: twentyeleven */
Typically, you’ll find the following headers in the stylesheet (style.css) of a WordPress theme:
Theme Name: The theme user sees this name on the WordPress Dashboard.
Description: This header provides the user with any additional information about the theme. Currently, it appears only on the Manage Themes page (Appearance→Themes).
Author: This header lists one or more theme authors. Currently, it is shown only in the Manage Themes page (Appearance→Themes).
Version: The version number is very useful for keeping track of outdated versions of the theme. It is always a good idea to update the version number when modifying a theme.
Template: This header changes a theme into a child theme. The value of this header tells WordPress the directory name of the parent theme. Because the child theme uses Twenty Eleven as the parent, the style.css needs to have a Template header with a value of twentyeleven (the directory name of the Twenty Eleven theme).
Now activate the new TwentyEleven Child theme as your active theme. You should see a site layout similar to the one shown.
The new theme doesn’t look quite right. The problem is that the new child theme replaced the style.css file of the parent theme, yet the new child theme’s style.css file is empty. You could just copy and paste the contents of the parent theme’s style.css file, but that method would waste some of the potential of child themes.