How to Create a WordPress Child Theme and allow updates

  1. Home
  2. Knowledge Base
  3. WordPress Themes
  4. How to Create a WordPress Child Theme and allow updates

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):

  1. Twenty Ten installed in the wp-content/themes/ folder.
  2. A folder with your Childs Theme name in the wp-content/themes/ folder.
  3. A style.css CSS file in the folder of your Childs Theme.

What could be additionally required:

  1. A functions.php file in the folder of your Childs Theme, to modify or add functions.
  2. Any additional file(s) you wish to modify from the Parent Theme: header.php, footer.php, etc.

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.

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):

  1. Rename your current Twenty Ten theme in the style.css CSS file by modifying the Theme Name line.
  2. Rename the twentyten folder your current theme is in.
  3. Download a clean up-to-date copy of the Twenty Ten theme into your wp-content/themes/ folder, dont activate it.
  4. Modify your newly renamed themes style.css CSS file by adding the Template: twentyten declaration.
  5. 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!
  6. Re-activate your newly created Child Theme.

Now you can happily let the Twenty Ten theme update eternally without loosing your modifications.

Was this article helpful?

Related Articles

Leave a Reply