How to Create Child Theme in WordPress

This quick tutorial will be showing you how to create child theme in WordPress. When a WordPress theme gets updated, all your customizations are lost, if you don’t create a child theme.

wordpress child theme

Step 1: Create the Child Theme Folder

Go to the main WordPress theme folder (wp-content/themes), where you will find all your installed WordPress themes. Then create the child theme folder for your current active theme. For example, if you current active theme is twentynineteen, you can name the child theme twentynineteen-child.

Step 2: Create the Stylesheet File

Under the child theme folder, create a styleshee file (style.css). Put the following lines into the file. Replace the name as necessary.

/*
     Theme Name: Twenty Nineteen Child
     Template: twentynineteen
*/

Step 3: Enqueue Parent and Child Theme Stylesheet

Create a functions.php file in the child theme folder. Put the following lines into the file.

<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
     wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
?>

Step 4: Activate Child Theme

Go to your WordPress dashboard -> Appearance -> Themes and activate the child theme.

Step 5: Customize Your Theme

Now whenever you want to customize your theme, for example, you need to change something in the footer.php file, you need to copy the footer.php to the child theme folder and make changes there.

Conclusion

I hope this article helped you create WordPress child theme.

Rate this tutorial
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *