Change Theme Using Child Theme in WordPress

I often select an existing WoredPress theme for my blog website, but normally I will NOT use the theme completely, I will change something in the theme due to my own requirement and my own style.

How I changed theme is using WordPress child theme mechanism: it is easy to understand, a child theme, it is a theme which can cover the original theme, but you do not need to write entire theme. The advantage is I also do not affect original theme, I do not need to change original theme directly.

For a child theme, you just create or copy the theme files to another folder which named like “xxx-child” (Note: all theme files located the folder wp-content/themes, the child theme folder also should be in this folder), you use the same file names, and change code in those files:

image

Normally, you do NOT need to copy all theme files, but you only need to create the following 2 files which are the necessary in a Child theme:

style.css
functions.php

About style.css:

In style.css, you can put all style which you like, but you MUST begin with the following similar format stylesheet header:

/*
Theme Name: Twenty Eleven Child
Theme URI:
http://wordpress.org/extend/themes/twentyeleven
Author: the WordPress team
Author URI:
http://wordpress.org/
Description: my changed theme
Version: 1.0.0
Text Domain: twenty-eleven-child
Template: twentyeleven
License:GNU General Public License v2 or later
License URI: 
http://www.gnu.org/licenses/gpl-2.0.html
Tags: …..
*/

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

(or using a wp_enqueue_scripts action and use wp_enqueue_style() in child theme’s functions.php. )

Since the child style.css will override parent’s style.css, so we must IMPORT parent’s style.css first (if use functions.php way then you do not need to use IMPORT in style.css)


About functions.php:

The functions.php of a child theme does not override the same functions.php in parent theme which is unlike styles.css. Instead, you put your own functions in your child functions.php and they will be loaded as like an extension functions file, but we have to know the child’s functions will be loaded BEFORE the parent’s file.

 

About more detail info of Child theme, please read official WordPress site here.