How to create a WordPress child theme
Home » BLOG » WordPress » How to create a WordPress child theme

How to create a WordPress child theme

category:  WordPress

If you are planning to do the customization (change the templates, CSS, or add more functionalities) on your site and your site is built by WordPress. You should create a child theme. Today, I am going to share “How to create a WordPress child theme”.

What are the benefits of the child theme

  • Keeping the changes you make after theme updates: If you change the templates, CSS or adding more functionalities to the active theme then the theme is updated, all changes you made are gone. With the child theme, your changes won’t disappear.
  • Save development time: Using the existing theme either free or paid version, will make development much faster. Instead of coding everything from scratch, you will use the parent theme as the core and make changes via the child theme.

There are many WordPress themes available for the free or paid version. They normally provide the demo site that you can preview. Some of them look professional. However, pick the quality one is challenging for non-technical people. The best way to find and buy the quality WordPress theme is HERE. Check it out and pick one to fit you need.

DO YOU KNOW

How to create a WordPress child theme

Let say your active theme is a TwentyTwenty Theme. In order to create the child theme, we will do 3 steps.

Create a new child theme folder

We create a new child theme folder as TwentyTwenty-child for the TwentyTwenty theme. You should not use space or underscore in the folder name. However, you can use a hyphen in the folder name.

Create a style.css

In the TwentyTwenty-child folder, create a style.css and add the code below.

/* 
Theme Name: Twenty Twenty Child 
Theme URL: http://yourdomain.com
Description: Twenty Twenty Child 
Theme Author: Apple Rinquest
Author URL: https://applerinquest.com
Template: twentytwenty 
Version: 1.0.0 
Text Domain: twentytwenty-child
*/

Change all the values accordingly. The most important field is Template. It tells WordPress which parent theme your child theme is based on.

Create a functions.php

In the TwentyTwenty-child folder, create a functions.php and add the code below.

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

That’s it. Our child theme is ready. At Appearance>Themes, activate the child theme you just made. You will notice your site looks the same as the parent theme. Now you can start to customize your code in the child theme folder.