Making Child Themes

We will use the excellent Generate Press theme (my latest favorite theme to customize) tonight to create a child theme.

I. Using the WordPress Codex as a model, please copy the following code into a plain text document, :

/*Theme Name: Learning Child Themes
Theme URI: http://dinaalcalaypearlman.com/learning-child-themes
Description: GeneratePress Child Theme
Author: Dina Pearlman
Author URI: http://dinaalcalaypearlman.com
Template: generatepress
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: learning-child-themes
*/

This will be your styles.css document for your future child sheet. We will modify the code accordingly (learn in class)

Then save it as styles.css taking care to make sure it’s a plain text document.

II. Then, copy first the functions.php of your theme, and replace the inside code with this code, save it into a plain text document:

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

}

OR

<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array(‘parent-style’)
);
}

Then save it as a functions.php document.

III. Put all of them in a folder naming it the name of your new theme (lower-case letters, please!)

IV. Zip the folder

V. Upload via FTP or through your Appearance/Themes dashboard.

Want to know how to get an image of your new theme? After you’ve customized it, make a screenshot, and call it “screenshot.png”, and FTP it to the inside of your child-themes directory. It’s that simple! It will automatically be included in your Appearance/Themes preview section!