So youve got a decent handle on how WordPress works, you may have even edited a few themes directly, but now those themes have updates, what do you do (better yet what should you have done)? You need to explore Child Themes. How do you actually create a child theme in WordPress you may ask? We will quickly explore what you need to create a Child Theme using the WordPress Twenty Ten theme as an example. Then we will detail how to allow those updates to occur without loosing your customizations to any theme.
What do you need to create your Twenty Ten Child Theme (the basics):
- Twenty Ten installed in the
- A folder with your Childs Theme name in the
style.cssCSS file in the folder of your Childs Theme.
What could be additionally required:
functions.phpfile in the folder of your Childs Theme, to modify or add functions.
- Any additional file(s) you wish to modify from the Parent Theme:
The magic happens in the CSS file of your Child Theme, namely the Template declaration line.
Adding this Template declaration in the CSS file tells WordPress to look for and run the Twenty Ten theme as a parent to this theme. The Child Theme will then get all the functionality of the Parent, but youll be able to modify the files without worry of being overwritten when the Parent Theme updates. Putting the Template declaration together with some of the common WordPress Theme declarations yeilds the code below.
Theme Name: Your New Child Theme Name
Theme URI: http://your_web_site.com/
Description: Custom theme for your_web_site.com.
Author URI: http://your_web_site.com/
Tags: all, the, tags, describing, your, new, theme
So what should you do if you have modified a theme and updates to the theme are available? Turn your current theme into a Child Theme. For the sake of clarity, lets assume youve modified the Twenty Ten theme. Follow these steps below (replacing your current themes name where weve used Twenty Ten):
- Rename your current Twenty Ten theme in the
style.cssCSS file by modifying the Theme Name line.
- Rename the twentyten folder your current theme is in.
- Download a clean up-to-date copy of the Twenty Ten theme into your
wp-content/themes/folder, dont activate it.
- Modify your newly renamed themes
style.cssCSS file by adding the Template: twentyten declaration.
- Remove all the files you did not modify from your new Child Themes folder (you can usually tell by file-date-time if your using an ftp client). Leave the original Twenty Ten ones alone from now on!
- Re-activate your newly created Child Theme.
Now you can happily let the Twenty Ten theme update eternally without loosing your modifications.