Create Webpages

Inform. Create. Fascinate – your website creation Blog

Child-Theme for WordPress – How you create it!

WordPress 3.0 has introduced a great new feature, which makes customizing your blog even more easy – the feature is called child-theme. With a child-theme you will be able to edit a theme the way you like, without changing its PHP-files and CSS-files. A child is a theme in itself, which uses the files of a parent theme. This offers quite new possibilities. When you update your theme, all your customized files in the theme folder will be overwritten. This means you will loose the customized view of your blog. Now, why should you update a theme? This may have several reasons. A possible reason is the addition of new features by the author. And: if you chose to use the wordpress standard theme(“twentyeleven”), then all your changes you made to this theme will get lost in case you update your wordpress installation. In this case, a child-theme allows you to keep all the changes you made. However, “twentyeleven” is the only theme that gets affected by a wordpress update.

Wordpress.org

How to use a child-theme

Setting up a child-theme is quite easy. Create a new folder in the themes-directory of your wordpress installation on your webspace. Name the new folder „yourtheme-child“ (replace „yourtheme“ with the name of the theme you want to customize ;-) ) Now open the style.css of your chosen theme and copy it to your child-themes folder.

Delete everything you see in the top area of the file and paste the following code in your new style.css:

1 /*
2 Theme Name: your chosen Theme-Child
3 Theme URI: http: //yourdomain.com/
4 Description: Child-theme for your chosen Theme
5 Author: Your name
6 Author URI: http: //yourdomain.com/
7 Template: your chosen theme
8 Version: 1.0
9 */

Now change everything like explained in the code snippet above and save the new style.css in your child-themes folder.
If you deleted every entry there, you will be able to import the settings to your child-theme by the line below:

@import url("../yourchosentheme/style.css");

This will import the style settings of the original style.css. However, you only have to perform one of the above mentioned measures. Either delete everything below the header in your style.css and entry the @import line or just keep the basic information in your style.css.

If you want to edit other files than the style.css just copy them into your child-themes folder and you are free to customize the files without editing the original ones. Now, an update will not affect any customizations you have done. Everything will be like you set it but you will be free to use a new version of the theme, if the author will release one. An update for a theme can have many reasons. Maybe the author fixed some bugs in the code of the theme or there have been some graphical issues before. Another reason why an author should update a blog is that he might add some additional features to the theme, e.g. SEO-features or some article sliders.

A special file is the functions.php. You will not be able to just copy this file to the child-themes folder, like you did with the other themes. The functions.php has to stay in the parents themes folder. If you want to edit the functions.php, you have to edit one of the lines in this file. To avoid any problems in the future you should definitely backup the original functions.php, so that you can restore the original file if needed.

If you follow these instructions you will be able to easily create a child-theme by yourself. You should try it, it´s really easy.

To get additional information about this topic, you can always visit the wordpress codex. The wordpress codex is a great source to get additional information about other topic too. If there are more things you aren´t sure about, you can always suggest any topics we should deal with in our articles or you can just browse through the archives, where you will find some more articles about different topics.

There is another great guide in the internet which shows you how you can create a child-theme for TwentyTen, which was once WordPress’ standard theme. So, if you are interested in creating a Child-theme for TwentyTen, then you should definitely check out Aarons Guide for creating a Child-theme. He explains all steps necessary to create a Child-theme for TwentyTen. Some problems which may occur are already handled in the comments, so it is worth checking them out.

Special tip in case you didn´t create a child-theme before customizing

There is another opportunity how you can save your customized theme settings if you want to update your theme. When you create your own customized files, don´t save the theme in the given folder. Instead, save it in a folder you created on your webspace within the wp-content/themes directory. Now you have the theme twice on your webspace, but this shouldn’t concern you too much since a theme normally isn´t bigger than 1 MB Now, imagine there is an update available for your theme. You decide to update and all your customizations get lost. Quite annoying, isn´t it. But since you have a copy of your folder, where all your customizations are located, just choose the copy of your theme folder in the wordpress backend. If you do so, your theme with all the customizations will be restored. In case your customizations won´t be adopted and you are not willing to do it all over again, just skip this update. It´s really easy to create a copy, so I really recommend to invest a couple of seconds to be on the safe side.

If you need more information about this topic please take a look at the entry for Child-Themes in the WordPress Codex. If you are looking for some basic information, then you should check our starting guide for wordpress.

VN:F [1.9.20_1166]
Rating: 4.3/5 (3 votes cast)
Child-Theme for WordPress - How you create it!, 4.3 out of 5 based on 3 ratings

Your email address will not be published. Required fields are marked *

*