Child Theme in wordpress

Create child theme in wordpress

If you’re using WordPress as your Content Management System (CMS) to build your website, it’s a good idea to create a child theme to ensure that your customizations are not lost when updating your theme. A child theme is a theme that inherits the functionality and styling of its parent theme, but allows you to make changes without affecting the original theme files.

In this blog, we’ll walk you through the process of creating a child theme in WordPress step-by-step.

Step 1: Create a new directory for your child theme

The first step is to create a new directory for your child theme. You can do this by using an FTP client, or by accessing your WordPress installation through your hosting account’s control panel. Navigate to the wp-content/themes directory and create a new directory with a unique name for your child theme. For example, if your parent theme is “Twenty Twenty-One”, you can name your child theme “Twenty Twenty-One Child”.

Step 2: Create a new style.css file

Next, create a new style.css file in your child theme directory. This file will contain the header information for your child theme. At the top of the file, add the following code:

Theme Name: Twenty Twenty-One Child
Theme URI:
Description: Child theme for the Twenty Twenty-One theme
Author: Your Name
Author URI:
Template: twentytwentyone
Version: 1.0.0

Replace the values for Theme Name, Theme URI, Description, Author, Author URI, Template, and Version with your own information. The Template value should match the directory name of your parent theme.

Step 3: Enqueue your parent theme’s stylesheet

To inherit the styling of your parent theme, you’ll need to enqueue its stylesheet in your child theme’s functions.php file. Create a new file called functions.php in your child theme directory and add the following code:


function twentytwentyone_child_enqueue_styles() {
	wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

add_action( 'wp_enqueue_scripts', 'twentytwentyone_child_enqueue_styles' );

This code uses the wp_enqueue_style function to enqueue your parent theme’s stylesheet. It retrieves the directory URI of your parent theme and appends “/style.css” to it. Step 4: Customize your child theme Now that you’ve created your child theme, you can start customizing it. You can add new styles to your child theme’s style.css file, or create new template files to override your parent theme’s templates. You can also add new functions to your child theme’s functions.php file. For example, if you want to modify the header.php template, you can copy it from your parent theme’s directory to your child theme’s directory and make your modifications there. WordPress will automatically use your child theme’s version of the template instead of the parent theme’s version. Step 5: Activate your child theme Once you’ve completed your customizations, you can activate your child theme by going to Appearance > Themes in your WordPress dashboard. You should see your child theme listed there. Click on the “Activate” button to activate it.

Congratulations! You’ve successfully created a child theme in WordPress. Now you can make changes to your website without worrying about losing your customizations when you update your parent theme.

For more in-depth information and a comprehensive guide on creating child themes in WordPress, please follow this official WordPress documentation link: WordPress Child Themes Documentation.

Leave a Reply

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