Creating Child Theme for WordPress

What is a Child Theme?

A child theme for WordPress is a child theme for the original theme with all its Functionality, Component, Features, Stylesheet, and more.

Why Child Theme?

If we need to make any changes in files like CSS, Php files and we make changes on the parent theme, so when the theme is updated all these changes will be lost. so here the child theme comes, we create a child theme and make changes to it.

How to create child theme in wordpress step by step?

Step 1

– Create a new folder in theme director at wp-admin/themes. The name of the folder is related to your parent theme so if your parent theme is like ( twentynineteen) then your child theme is ( twentynineteen-child ).

– Now we need to add some files in our child theme folder like: style.css and function.php. These 2 files are compulsory to create in child theme.

Step 2

– Create a file and rename it as style.css. and add the below content as a comment as shown below

/*  
	Theme Name:   Twenty Nineteen Child  
	Theme URI:    http://example.com/twenty-nineteen-child/  
	Description:  Twenty Nineteen Child Theme  
	Author:       John Doe  
	Author URI:   http://example.com  
	Template:     twentynineteen  
	Version:      1.0.0  
	License:      GNU General Public License v2 or later  
	License URI:  http://www.gnu.org/licenses/gpl-2.0.html  
	Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready  
	Text Domain:  twentynineteenchild 
*/ 

In the above code these are the required to add in code:

  1. Theme name is for unique child theme name.
  2. Template is the name of the parent theme directory name like your parent theme folder name is ( twentynineteen ) then Template is twentynineteen

Step 3

– Create a file and rename it as functions.php. this file is used to add your parent theme CSS to your child theme and also creating new functions you need for your website. the below code is for enqueuing the parent theme stylesheet.

<?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' );
	}

When you add this code in your functions.php file it will call all CSS of your parent theme into your child theme.

Step 4

Activate your child theme From your Admin Dashboard and now Your child theme is exactly like the parent theme and you can add CSS to your child theme. If you need to edit something like in the header.php file, you just need to copy the header.php file from your parent theme and paste it into child theme make changes what you need to do. same for the other files like footer.php etc.

That’s it. now your child theme is complete.

2 thoughts on “Creating Child Theme for WordPress”

  1. kyrie 5 spongebob

    I must express appreciation to the writer for rescuing me from this particular matter. After scouting through the online world and getting methods which are not beneficial, I thought my life was gone. Being alive without the presence of solutions to the difficulties you have sorted out by means of your good report is a serious case, and the kind which could have negatively damaged my entire career if I had not noticed your site. That know-how and kindness in playing with every part was invaluable. I don’t know what I would’ve done if I had not encountered such a subject like this. I can now look forward to my future. Thank you so much for the skilled and amazing guide. I won’t hesitate to recommend your site to any person who should receive guidelines about this matter.

Leave a Comment

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

Scroll to Top