A Child Theme in WordPress is simply a “style only” Theme, and is easily made by adding Template: themefolder to your style’s header.
The basics of creating a Child Theme
If you want to create a Child Theme to Basic2Col your style.css header will turn out:
/* Theme Name: My theme Theme URI: http://mysite.tld/ Description: My Basic2col Child Theme Version: 1.0 Author: Me Author URI: http://mysite.tld/ Tags: Child Theme Template: basic2col */
As you see the last line says: Template: basic2col. This will tell WordPress that your theme will use Basic2Col’s template files instead of having their own.
Other files you can add (by default) to your Child Theme is functions.php and screenshot.jpg/png/gif.
If you want to add other template files to a Child Theme and make them override the template files of the Parent Theme, you need to have the WordPreciousss plugin installed on your site.
When to use Child Themes
In basic a Child Theme is best to use when you want to make style only changes, which can be good if you’re perfectly happy with the functionality of a theme but want it look differently.
Another benefit is that you can leave the style.css of the Parent Theme alone, so you don’t have to worry about losing any layout/ css changes you’ve made.
Some themes also have filter and action hooks you can use for even more customization of your Child Theme, using the Child Theme’s functions.php file. But this does of course requires some php knowledge.
Things to remember when creating Child Themes
When creating a Child Theme you start out with no styling whatsoever and if you wish to make use of the style in the Parent Theme you need to import it.
The value set in
Template: should be the name of the directory to Parent Theme, not the name of the Theme itself.
If you edit or add any template files to the Parent Theme it will affect both themes.
If you delete or rename the Parent Theme’s directory your Child Theme will break.
If you decide to use a functions.php file in your Child Theme you need to remember that any codes/ functions you add to it is in addition to the codes/ functions found in Parent Theme’s functions.php file.
- WordPress Codex: Theme Style Sheet
- Themeshaper: How To Protect Your WordPress Theme Against Upgrades
- Themeshaper: How I used a WordPress Child Theme To Redesign My Blog The Smart Way
- Designing For Sandbox (Sandbox calls the Child Themes “Templates” or “Sandbox Designs“)
These themes has extended theme functionality with action and filter hooks so you can get more of your Child Theme:
* Both Tarski and K2 has built in options for adding new styles to the theme.
** Basic2Col 3.1 has some built in options for overriding template files in the Child Theme, but have not as much actions and filters as the other themes mentioned.