How to Create a Child Theme

WordPress has a Child Theme Handbook teaching you all about it. This blog is running with one I’m still developing (for the Twenty Twenty Theme)

About the tools; to bare in mind:

  • To develop a Child Theme, all you need is a Text Editor; however, using Sublime Text is game changing
  • To install a Child Theme, however, you’d need a self-hosted website, or a WordPress.com plan (Business or Commerce)

If you’re feeling lazy, 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: Have fun!

Step 5: Upload Your Files to Your Server

Follow Laly on WordPress.com