how to create a wordpress child theme

how to create a wordpress child theme

A WordPress child theme is a theme that inherits its functionality from another theme, called the parent theme. Child themes are often used when you want to make customizations to an existing theme without modifying the original theme files. This allows you to update the parent theme without losing your customizations.

Child themes are also useful if you want to create a new theme that builds upon the existing design and functionality of an existing theme. By using a child theme, you can save time and effort by not having to start from scratch and can focus on adding your own customizations and features.


To set up a child theme in WordPress, you will first need to create a new folder on your web server and give it a unique name. Inside this folder, you will need to create a file called “style.css” and add the following code to it:

Theme Name: [Name of your child theme]
Theme URI: [Link to your child theme]
Description: [Description of your child theme]
Author: [Your name]
Author URI: [Your website]
Template: [Name of the parent theme]
Version: [Version number of your child theme]

/* Custom styles for the child theme go below this line */


Next, you will need to create a “functions.php” file in the same folder and add the following code to it:


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

This code tells WordPress to load the styles from the parent theme first, followed by the custom styles in your child theme.

After that, you can activate your child theme from the WordPress admin panel by going to Appearance > Themes, and clicking on the Activate button next to your child theme. Once activated, you can start customizing your child theme by modifying the styles in the “style.css” file or by adding new functions to the “functions.php” file.