How to Create 2022 Child Theme – WordPress Theming

To Create Child Theme of WordPress 2022 Theme, create a folder in your \wp-content\themes folder, name whatever you would like to call it. I named it 2022-child

mkdir \wp-content\themes\2022-child

Create minimum required files in this folder.

Create style.css

touch \wp-content\themes\2022-child\style.css

Copy and paste the following code in your style.css file and save it.

/*
Theme Name:     2022-child
Theme URI:      
Description:    Twentytwentytwo child theme.
Author:         Me
Author URI:     
Template:       twentytwentytwo
Version:        0.1.0
*/

Create functions.php

touch \wp-content\themes\2022-child\functions.pnp

Copy and paste the following code in your functions.pnp file and save it.

<?php
/**
 * 2022-child Theme functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package 2022-child
 */

add_action( 'wp_enqueue_scripts', 'twentytwentytwo_parent_theme_enqueue_styles' );

/**
 * Enqueue scripts and styles.
 */
function twentytwentytwo_parent_theme_enqueue_styles() {
	wp_enqueue_style( 'twentytwentytwo-style', get_template_directory_uri() . '/style.css' );
	wp_enqueue_style( '2022-child-style',
		get_stylesheet_directory_uri() . '/style.css',
		array( 'twentytwentytwo-style' )
	);

}

Activate this 2022 child theme from your wp-admin area.

Create 2022 child them with wp-cli

NOTE: You must have wp-cli installed on your system to run this wp command.

wp scaffold child-theme sample-theme --parent_theme=twentysixteen