How To Make A Child Theme

A child theme is used when you plan to change or add new functionality to your theme.

Eduard Ungureanu avatar
Written by Eduard Ungureanu
Updated over a week ago

Note: If you are only using CSS customizations, having a child theme is not required and you can place your custom css code in Divi > Theme Options > General Tab > Custom CSS. If you plan on modifying theme template files (style.css or header.php) then you will need to create a child theme to retain those changes when updating. You can also find a great in-depth guide from our blog here.  

There are two ways you can create a child theme:

  • Using a 3rd party plugin

  • Coding it from scratch

Using a 3rd party plugin

There are many 3rd party plugins in the WordPress Plugin Repository that you can use. The top choice would be Child Theme Configurator: https://wordpress.org/plugins/child-theme-configurator/ - Child Theme Configurator is a fast and easy-to-use utility that allows you to analyze any theme for common problems, create a child theme and customize it beyond the options of the Customizer. 

There are many other child theme generator plugins that you can use. For more information browse this page: https://wordpress.org/plugins/search/child+theme/

Coding the child theme from scratch

Coding a child theme from scratch is actually easier than it sounds. All we need is a code editor like Sublime Text or VS, or any other code editor will work.

On your local computer, create a new folder. Usually, the name of the folder is divichild. The name of the folder can be anything you want.

Inside the folder create the first file we need, which will be a .css file called style.css.

  1. In style.css place this code:

/*
Theme Name: Divi Child Theme
Theme URI: http://yourwebsite.com
Description: Child Theme For Divi
Author: Your Name
Author URI: http://yourwebsite.com
Version: 1.0.0
Template: Divi
*/
  • Theme Name: it's the child theme name, it can be anything you want, usually I use Divi child theme

  • Theme URI: it represents the author website, where the page URL where people can find out more about the child theme we are creating

  • Description: a short description of your child theme, you can include things like: color scheme used, features added, etc

  • Author: Usually is your name, the person that has created the Child theme

  • Author URI: Could be your business website, or it can be the actual URL of the website where the child theme is used

  • Template: It is the parent theme name folder. Note: this name should be exactly as the folder name of the parent theme, if you have changed the Divi default folder to a different name, then that should be reflected in the Template option.

2. The second file that we will need is called functions.php and it will contain this PHP code:

<?php
/*================================================
#Load the Parent theme style.css file
================================================*/
function dt_enqueue_styles() {
$parenthandle = 'divi-style';
$theme = wp_get_theme();
wp_enqueue_style( $parenthandle, get_template_directory_uri() . '/style.css',
array(), // if the parent theme code has a dependency, copy it to here
$theme->parent()->get('Version')
);
wp_enqueue_style( 'child-style', get_stylesheet_uri(),
array( $parenthandle ),
$theme->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'dt_enqueue_styles' );

That's all there is, at this point, you will have a child theme for Divi.

Note: the same process can be applied for creating a child theme for Extra, the only difference is that in the style.css file the Template: Divi will be replaced with Template: Extra.

Did this answer your question?