How to Create a Child Theme

By Laurie M. Rauch

about:me

lauriemrauch.com

codediva.com

@lauriemrauch

WordCamp Buffalo 2012

What is a child theme?

A theme that is dependent on a parent theme for its code, but allows you to modify that theme to change its design and functionality.

With a child theme, you can change this...

Themify's Elemin Theme

Themify's Elemin Theme

To this...

JimmyDanko.com

Jimmy Danko (coming soon)

And from this...

StudioPress's Genesis Theme

StudioPress's Genesis Theme

To this...

CarmenSognonvi.com

CarmenSognonvi.com

And from this...

Graph Paper Press's Modularity Theme

Graph Paper Press's Modularity Theme

To this...

Heidi Baker

Heidi Baker

JumpingSunshineStudio.com

JumpingSunshineStudio.com

PrinciplePictures.com

PrinciplePictures.com

Why use a child theme?

How do you use a child theme?

What to look for in a parent theme

Where do you find a parent theme?

How it works

The child theme process

Let's Get Started...

Step 1

Create a style.css file

/*
Theme Name: Buffalo Child Theme
Theme URI: http://buffalowordcamp.com
Description: Custom child theme for Twenty Twelve
Author: Code Diva
Author URI: http://www.codediva.com
*/
	

Step 2

Add the Template name and the Parent theme's name

/*
Theme Name: Buffalo Child Theme
Theme URI: http://buffalowordcamp.com
Description: Custom child theme for Twenty Twelve
Author: Code Diva
Author URI: http://www.codediva.com
Template: twentytwelve
*/
	

Step 3

Import the parent theme's style.css file

/*
Theme Name: Buffalo Child Theme
Theme URI: http://buffalowordcamp.com
Description: Custom child theme for Twenty Twelve
Author: Code Diva
Author URI: http://www.codediva.com
Template: twentytwelve
*/

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

Step 4

Add a screenshot.png file

The screenshot in Appearance > Themes

Step 5

Upload your new theme to wp-content/themes

The themes folder structure

Step 6

Activate your new theme in Appearance > Themes

Activate your child theme

Start adding your changes

How do I edit my code?

Create a new file: functions.php

Functions written in this file will be added to the theme

Do not duplicate the parent theme's functions.php or you could get errors. This is the only file we add to instead of duplicating.

Unless...

The parent theme set up the function with this conditional:

		if ( ! function_exists( 'function_name' ) ):
	

This conditional allows you to create a new function with the same name that will replace the existing function.

Take a look...

Replace existing files with your revised version

Add cool stuff

Take a look...

Add a new page template

You can create as many page templates as you like. These will appear in the list on your Page edit page.

Page Template list
  1. Add the Template Name
    <?php
    /*
    	Template Name: Links
    */
    ?>
    			
  2. Add your header call
    			<?php get_header(); ?>
    			
  3. Add your footer call
    			<?php get_footer(); ?>
    			
  4. Add your new content

Take a look...

Add a little pretty...

Start adding new styles to your style.css to start changing the look of your theme.

Get help with learning CSS:

Take a look...

The Essentials

Stand back and admire your awesomeness

Questions?

Resources

Thank you!

This presentation is available at: http://codediva.com/wcb12. The slides were built using HTML5/CSS3 and may not work as well in older browsers or mobile devices

Download the child theme we created here: http://codediva.com/wcb12/buffalo.zip.