Can I just start by saying how embarrassed I am that I did not know how to do this before? Not that it is by any means a trivial skill… but the number of times that I have put myself in serious development danger by not learning this skill.. it makes me cringe.

What is a child theme:

  • A child theme is a way to modify portions of your theme without losing the original functionality and support of the parent theme. The parent theme files are still used to load your theme but you can add additional functionality or overwrite styles from the child theme folder.

Why creating a child theme is so important:

  • If you edit even a single character in your theme folder then you risk losing this edit if the theme is ever updated.

How to create a child theme

  • Copy your theme folder and append it with “-child”
  • Create style.css and functions.php files in your new child theme folder

At the top of your style.css file add the following block:

/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Description: Twenty Fifteen Child Theme
Author: John Doe
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: twenty-fifteen-child
*/

I have bolded the sections that you should customize for your own purpose. The most important part here is that you include the “Template: twentyfifteen” to refer to the folder of theme that your child theme is based.

Next edit the functions.php file to enqueue the parent and child stylesheets.

<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}
?>

That’s it! You should now be able to turn on your child theme.

Things to note:

  • If you add code to functions.php in your child theme it will be loaded AS WELL as the code in functions.php of your parent theme.