My Playground

How to make a simple child theme In wordpress

Asif Nawaz

Writen on June 9, 2013

Category: Tutorial, Wordpress

WordPress has a nice templating system. This is one good reason for it’s great publicity. Anyway we can start working now.

Why we need child theme?

Good question, suppose you have bought a wordpress theme/template and started a site, after some days you will get notification that the theme provider provided an update. You can’t update the theme because you have already applied modification on it. This is why child theme rocks. You can update your main theme anytime without breaking your modification.

 

How to make a child theme?

First of all, we need to declare a new theme. For example our theme name is “theonepager”. Now we need to make a new directory name “theonepager-child” (you can use any name actually) beside the main theme folder. You can do it from cpanel file manager.

Here is one screenshot of the main theme and child theme position,

child-theme-cpanel-file-manager

 

Now enter in the  child theme folder and make a new file from New File navigation button (at top left) and file name should be “style.css”. Select the file (style.css) and click on “code editor” (on nav), a dialog box will appear click on edit button.

See below which text should be added at the very top of the blank css file. Actually we are going to add some info in the stylesheet as comment and a css importing statement.

/*———————————————————–

Theme Name: theonepager child theme
Template: theonepager
Author: asifsaho
Author URI: http://www.asifsaho.me
Designed & Developed by asifsaho
Theme URI: http://www.asifsaho.me
License: GNU General Public License version 3.0
/*
=================================== */

@import url(../theonepager/style.css);

Carefully add the main theme css file in the @import css tag.  Actually all info is not mandatory without the info are showing in the below screenshot.

 

child-theme-stylesheet

 

Yes we are almost done. now to to Wp Admin Panel and then you will see a new theme, name “theonepager-child” as below screenshot.

 

 

Now activate the Child theme and write your all modification CSS which will override the main theme CSS. Also you can copy any theme file from from main theme folder to the child theme folder if you want to customize it as your need.

The files will get most priority which you will put in the child theme folder. That’s it!

Cool! now update your the main theme anytime without any data loss ;)