When dealing with WordPress it often happens that you end up using one of the fabulous themes that exist in large amounts and for all tastes.

Finding a theme is a time consuming quest on itself. Once you think you’ve found a candidate, you will have to review the features and compare them to your needs.

Anyway ! Let’s say you’ve finally found the Holy Grail of theme that is going to cheer up your day. BUT…it is not 100% as you want it to be  (it never is….), and you want to make some changes.

That is where WordPress child theme mechanism goes in !

Why use a child theme

  • To avoid tempering with the main theme (which could bring a disaster if  you haven’t backed it up before)
  • Usually, themes are upgraded by their author and you are warned about it. If you upgrade your theme with its new version you may loose your own modifications.
  • When maintenance day comes in you know where all your customs are.

How to implement the solution

Its fairly easy! If you work with WordPress, you should know by now that all themes are to befound in: /wp-content/themes/

Ok. Let’s say now that your theme is called the Holly and that your theme files are contained inside the folder names theholly.

  1. Create a directory in themes that you will name theholly-child.
  2. Inside that directory you are going to copy the style.css file present in the original theme theholly.
  3. Now, open the style.css file inside theholly-child and type the following code
    Theme Name: The Holly Child
    Description: Child theme for the The Holly theme
    Author: Your name here
    Template: theholly
    @import url("../theholly/style.css");
        color: #CCC;
  4. Save the file.
  5. Now, activate your child theme inside your WordPress dashboard.

What we’ve done here is keep mainly everything from the main theme but we modified the color of the h1 tag without touching any bit of your main theme.

This important line in your child css is

Template: theholly

Now, you can really go further on by adding copied files, from your main theme to your child theme, you want to modify. If you want to modify the header file, just put it in you child theme folder and all its modifications will override the header file of the main theme.

Et voilà ! You can read more just here.