How to Create a Child Theme

A “Child Theme” is like a patch we put on a “parent” theme, and it behaves almost as if it were simply a theme. For this reason, it is extremely important that you:

  1. Have the parent theme installed in your blog
  2. Upload your child theme (see step 4), in its own folder, separately from the parent theme (not inside)

WordPress has a Child Theme Handbook teaching you all about it. However, you may be not want to read the whole handbook now and there are basically five steps to get you started.

There are a couple of things to bare in mind though:

  • To develop a Child Theme, all you need is a Text Editor; however, using Sublime Text is game changing. And, if you develop it on a local host you’d work more efficiently.
  • To install a Child Theme, however, you need a self-hosted website, or a WordPress.com plan (Business or Commerce)

Here’s how you create a child theme:

Step 1

Create a Folder and name it twenty-twenty-child (for instance)

Step 2: A Style CSS file

Open Sublime Text and create a new file (or open your Text Editor and create a new file in plain text) and write with the following:

/*
Theme Name:   Twenty Twenty Child
Description:  A child theme for Twenty Twenty
Author:       Your Name
Author URI:   https://yourblog.com
Template:     twentytwenty
Version:      1.0.0
License:      GNU General Public License v2 or later
License URI:  http://www.gnu.org/licenses/gpl-2.0.html
Tags:         two-columns, right-sidebar
Text Domain:  twenty-twenty-child
*/

Save the file as style.css.

Step 3: a Function PHP file

Same step: open Sublime Text and create a new file (or open your Text Editor and create a new file in plain text) and write with the following:

<?php
//Child theme for twenty twenty
function my_theme_enqueue_styles() {
 
    $parent_style = 'twentytwenty-style'; // Make sure here it's the parent theme.
 
    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 ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

?>

Save it as functions.php.

Step 4: Upload and Install Your Child Theme

To install your child you’ve got two options: upload it from the WordPress dashboard or through FTP.

Installing a Child Theme From the WP Dashboard

This is as simple as installing any theme:

  1. Zip you child theme’s folder
  2. At your blog, go to Apperance > Themes, and click on “Add New”
  3. The window will refresh giving you the chance to choose the zip file from your machine.
  4. Once you’ve uploaded it, click on “Install Now”

WordPress will check that the parent theme is installed. It will take a few seconds and then you’ll be able to activate it.

If you’d customized your parent theme (site identity, colors, etc), these changes will be gone. You might need to select again your menus, widgets, etc.

Installing a Child Theme Trough FTP

Once you are logged in to your FTP, open wp-content > themes. You should see your theme’s folders there. Grab your child theme’s folder (not a zip file!), and drag it inside “themes”.

Then, head over to your WordPress dashboard, go to Apperance > Themes, and click on your Child Theme to activate it.

Laly York. Neurodivergent Gen-X writer / B.Ed. / Lawyer. Writing, coding and taking pics. From Jupiter, living in a soap opera; flying on the web with three blogs.

JOIN COMMENTS

Any thoughts?