Why we need a child theme

Using a child theme allows us to change or update our theme without losing our customizations. Without a child theme, we’d have to edit our theme files directly and any time we updated the theme, our customizations would be lost.

Now that you understand the importance of child theme in WordPress, let’s look at the steps of creating and activating child theme together.

How to create child theme in WordPress step by step

Here our parent theme is Blocksy, but if your theme is Astra or any other theme, the steps are the same.

Step 1: Get Text Domain of the current theme

In the WordPress dashboard, go to the following address:
Appearance -> Theme File Editor

Your active theme Stylesheet file is selected by default, otherwise select your main theme Stylesheet file to display its content.

Edit Stylesheet file in WordPress theme
Edit Stylesheet file in WordPress theme

As you can see in the image above, the Text Domain of parent theme is blocksy, copy this word somewhere because we will need it. (Your Text Domain will vary depending on your active theme)

Step 2: Create child theme files and folder

Create a folder on your computer and rename it to blocksy-child. (Text Domain in step above-child)

Make two text files in the above folder and rename them as follows:

Wordpress child theme files
WordPress child theme files

Open the functions.php with your favorite text editor and copy and paste the following code and save it.

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

Open the style.css with your favorite text editor and copy and paste the following code and save it.
* Please change the Theme Name to the name of your choice (chosen name doesn’t matter)
* Please change the Template to your Text Domain in step 1

Theme Name: My Custom blocksy theme
Template: blocksy

Your child theme is now ready.

Step 3: Zip the theme folder and install it on your site

zip wordpress child theme
Zip your WordPress child theme

Go to the WordPress dashboard and the Appearance section.
Appearance -> Themes -> Add New

Install Custom Child theme in WordPress

Click on Upload Theme and in the form that appears, use the Choose Files button to upload and install the theme zip file that you created in the previous step. After you see the installation success message, go back to the theme section and activate your uploaded theme.

If this article is difficult for you to read in text, you can watch the video version below.

That’s it, if you have any questions, please ask in the comments section so we can answer.

Share this post

Hi, my name is Maya and I’m a WordPress plugin developer. I created this website to share some of the helpful codes that I’ve used in my own projects.
If you’re looking for a custom plugin for your website, you can contact me by clicking on Hire a developer in the menu. I’d love to hear from you.

Articles: 50

Leave a Reply

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