Create a WordPress Child Theme

by Yang Yang on June 26, 2012

WordPress amazes by making things possible in the simplest and most intuitive way. Child themes are the intended and correct way for customizing a third-party theme and you should always create a child theme to do the customizations so that the original theme stays intact thus ready for upgrade. And this is how you can do it with a file that’s just a few lines.

Follow the steps. Create the child theme folder and its style.css.

How to create a WordPress child theme?

  1. Create a folder in /wp-content/themes and name it however you like as this would be your child theme directory. For instance, you are creating a child theme from Twenty Eleven, and you may name it twentyeleven_one, twentyeleven_two, or something.
  2. Create a style.css file in the new directory and put in the following lines in it:
    /*
    Theme Name:     Twenty Eleven Child One
    Template:       twentyeleven
    */
    
    @import url("../twentyeleven/style.css");
    
  3. That’s it. Now head to Appearances -> Themes and refresh the page to see the new theme that you can activate.

The bold part of the above code is the folder name of the parent theme, so this child theme knows which parent theme it is inheriting from.

Activating Child Theme & Customizations

After you have activated the child theme, everything will be the same as if you have activated the parent theme. And you can overrule the same file in the parent theme by creating an identically named file in the child theme, including .php, .css, .js, .jpg, etc. Note however, you can’t overrule files in a sub-folder of the parent theme.

For example, you can now write some CSS styles in the style.css you just created and it will be overwriting existing styles in style.css in the parent theme directory.

Any customizations to the theme files will be only in the child theme so the parent theme will be free and ready to be upgraded thus preserving your changes.

Shreyo October 11, 2012 at 2:22 am

i would like to know about using a theme framework for creating a wp theme (for e.g: wonderflux framework)

Comments on this entry are closed.

Previous post:

Next post: