WordPress Child Theme

Are you thinking about how I can customize my theme without losing before edits? This article will teach you how to create a child theme in WordPress without any plugins. We will talk about the WordPress child themes and how to make them in the following.

What is Child Themes

WordPress child themes allow developers or anyone to customize your active theme without losing customization on your theme. If you use the default WordPress theme for editing after any updates, your changes will be removed. So the solution is a child theme.

Create Child Theme

Now we will create a WordPress child for our active or any theme that you want. The first thing we need to do is open the public directory on your hosting panel. Then go to wp-content->themes.

Create Child Theme Folder

Create a new folder called yourthemename-child. You should Replace your theme name with yourthemename. For example, we are using the twentytwentyone. So our folder will be twentytwentyone-child. It is possible that your theme has a different name and you must change the twentytwentyone.

WordPress Child Themes Name
WordPress Child Theme Name

Create Files

The second thing that you must do is create files called the style.css and functions.php. So first create files and then open them with a text editor like VSCode or notepad. Then add these codes to files.

This code is for style.css.

 Theme Name:   Twenty Twenty-One Child
 Theme URI:    http://example.com
 Description:  This is a Child Theme for Twenty Twenty-One Theme
 Author:       Clazist
 Author URI:   http://example.com
 Template:     twentytwentyone
 Version:      1.0.0
 Text Domain:  twentytwentyonechild

Replace the Template value with your theme name. And now you should add this code to the functions.php.

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_uri(),
        array( 'parenthandle' ), 
        wp_get_theme()->get('Version') // this only works if you have Version in the style header

Activate Theme

Now go to the WordPress admin dashboard and click on Appearance->Themes and you have a new theme called the Twenty Twenty-One Child. Click on activate to active theme. Now you can edit the child theme without losing your changes after any updates.

Active WordPress Theme
Active WordPress Theme