Creating A Child Theme

This allows you to modify a main theme but still allow the main theme to be updated.

The main guide:

Creating The New Theme

1. Creat a new directory for the child theme, typcially “main_theme_name-child”

2. Create a file called “style.css” and paste this into it:

 Theme Name:     Twenty Thirteen Child
 Template:       twentythirteen

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

/* =Theme customization starts here
-------------------------------------------------------------- */

Change to match the theme you are making a child of.

This css file is included after the parent theme so anything here will take precedence.

3. Activate the child theme in wordpress.

Customizing other files

The child theme can overwrite any file in the parent theme simply by copying the file from the parent theme into the child theme directory and customizing it.  That file will them be used instead of the parent theme’s header.php.

You can also include files in the child theme that are not included in the parent theme. E.g. you might want to create a more specific template than is found in your parent theme, such as a template for a specific page or category archive.

Functions.php customization

functions.php in a child theme is loaded in addition not instead of its counterpart from the parent theme.

Basic empty file:


Customizing existing functions

A child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally:

if ( ! function_exists( 'theme_special_nav' ) ) {
    function theme_special_nav() {
        //  Do something.

This way a child theme can replace a PHP function of the parent by simply declaring it beforehand. 

Doing things after the main themes functions.php file

For instance call set_post_thumbnail_size() to override its call of the function

add_action( 'after_setup_theme', 'my_child_theme_setup', 11 );		//11=Run with a later priority

if ( ! function_exists( 'my_child_theme_setup' ) ):
	function my_child_theme_setup()
		if ( function_exists( 'add_theme_support' ) )
			add_theme_support( 'post-thumbnails' );
			set_post_thumbnail_size( 200, 200, true );
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published.