How to Create a Child Theme of any WordPress Theme

To create a child theme of any WordPress theme, you can follow these steps:

  1. Create a new folder: Start by creating a new folder for your child theme in the “wp-content/themes” directory of your WordPress installation. Choose a name for your child theme and create a folder with that name.
  2. Create a stylesheet file: Inside the child theme folder, create a new file named “style.css”. This file will contain the CSS rules for your child theme.
  3. Add the required information: Open the style.css file and add the following required information at the top of the file:
/*
 Theme Name:   My Child Theme
 Theme URI:    https://codingissimple.com/my-child-theme/
 Description:  Child theme for My Parent Theme
 Author:       Ethan Anderson
 Author URI:   https://codingissimple.com
 Template:     parent-theme-folder-name
 Version:      1.0.0
*/

Replace “My Child Theme” with the name of your child theme, “https://codingissimple.com/my-child-theme/” with the URL of your child theme (if applicable), “Child theme for My Parent Theme” with a description of your child theme, “Ethan Anderson” with your name, “https://codingissimple.com” with your website URL, and “parent-theme-folder-name” with the folder name of the parent theme.

  1. Enqueue the parent theme stylesheet: In the same style.css file, add the following code to enqueue the parent theme’s stylesheet:
/* Theme Name: My Child Theme */
@import url("../parent-theme-folder-name/style.css");

Replace “parent-theme-folder-name” with the folder name of the parent theme. If you import the parent theme’s stylesheets using @import in the child theme’s style.css file, it may prevent you from properly overriding the parent theme’s styles. Instead, it’s recommended to enqueue the parent theme’s stylesheet using the wp_enqueue_style() function in the child theme’s functions.php file.

function child_theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );
  1. Create a functions.php file (optional): If you want to modify the functionality of the parent theme, you can create a functions.php file in the child theme folder. This file will be loaded automatically when the child theme is active. Add your custom PHP code in this file to modify the theme’s functionality.You can enqueue parent themes’ style in this file.
  2. Activate the child theme: Log in to your WordPress admin dashboard and navigate to “Appearance” -> “Themes”. You should see your child theme listed. Click the “Activate” button to activate the child theme.We don’t need to upload the zip file of child theme here because we started creating the child theme already inside the themes folder.

That’s it! You have successfully created a child theme of a WordPress theme. Any modifications you make to the child theme’s stylesheet or functions.php file will override the corresponding files in the parent theme, allowing you to customize the appearance and functionality of your website while preserving the ability to update the parent theme without losing your changes.

Also read How to add favicon to wordpress website

How to run wordpress website on localhost

Don't Miss Out! Subscribe to Read Our Latest Blogs.

If you found this blog helpful, share it on social media.

Subscription form (#5)

Leave a Comment

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

Pin It on Pinterest

Scroll to Top