Knowledge for the World

How to create a child theme in Wordpress

  • by Zach (134)
  • 10 minutes

Wordpress instituted the child theming system for Wordpress so that you can upgrade parent themes (i.e. twentyeleven) when updates are available for them -- without wiping out your changes. In this way, you're technically using two themes -- the parent th

1

Using your favorite FTP/SFTP program (or the command line), upload the parent theme you will be using. For example:

http://domain.com/wp-content/themes/twentytwelve/
2

In /wp-content/uploads/, create a folder for your child theme. You can call it whatever you want, but for simplicity's sake I normally just append the term "-child" to the name of the parent theme. For example:

http://domain.com/wp-content/themes/twentytwelve-child/
3

Create a new file called style.css and upload it to the child theme directory. For the child theme to be recognized by Wordpress, the information below must be contained in this file:

/*
Theme Name:     Twenty Twelve Child
Theme URI:      http://example.com/
Description:    Child theme for the Twenty Twelve theme
Author:         Your name here
Author URI:     http://example.com/about/
Template:       twentytwelve                             
Version:        0.1.0
*/
4

Place the below code on the first line of your newly created style.css, changing "twentytwelve" to your parent theme's directory:

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

Any changes you make to this file will override the parent theme's CSS. For example, let's say your parent theme (twentytwelve) has the following CSS:

body { background: #777; }

.. and you want to change the background color to #666. You would open your new style.css file, copy the above code and change it as follows:

body { background: #666; }

By default, the #666 value would be used.

5

In the Wordpress control panel, navigated to Appearance > Themes and Activate the child theme.