Skip to main content
How to Create a Child Theme for Divi

Create a Divi Child theme for adding PHP and other types of customizations?

Updated over 6 months ago

A child theme is a sub-theme that inherits all the functionality and style of the main theme, also called the parent theme. Child themes are a safe way to modify an active WordPress theme without directly altering it.

Using a Child theme will ensure that any customization is preserved when the parent theme is updated.

Notes:

  • Having a Child theme is not required if you only use CSS customizations. You can place your custom CSS code in Divi Theme Options General Tab Custom CSS.

  • If you plan to modify Divi's theme files, such as header.php or footer.php, you will need to create a Child theme to retain those changes when updating.

  • For more information, you can also check the Ultimate Guide to Creating a Divi Child Theme guide.

There are two ways you can use to create a child theme for Divi:

Using the Child Theme Configurator third-party plugin

  1. Log in to the WordPress Dashboard

  2. Go to Plugins → Add new

  3. Install it and Activate it

  4. Go to Tools → Child Themes

  5. Ensure the Create a new Child Theme option is selected

  6. Ensure that Divi is selected as the Parent Theme

  7. Click on the Analyze button

    Child theme configuration - initial setup

  8. Choose the Primary Stylesheet (style.css) option

  9. Choose Use the WordPress style queue option

  10. Click on the Create New Child Theme button

    Child theme configuration - initial setup

  11. Go to Appearance → Themes and activate the new Child Theme

Creating the Child Theme from scratch (advanced)

Creating a child theme from scratch is easier than it sounds. We only need a code editor, such as VS Code, Sublime Text, or any other code editor.

  1. Create a new folder on your local computer and name it divi-child

  2. Inside the divi-child folder, create a new file called style.css and place the following CSS 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
    */

    1. Theme Name: It's the child's theme name. It can be anything you want. Usually, I use Divi's Child Theme

    2. Theme URI: Represents the child theme author's website URL.

    3. Description: a short description of your child's theme. You can include things like color scheme used, features added, etc

    4. Author: The person's name who has created the Child theme

    5. Author URI: This could be your business website, or it can be the actual URL of the website where the child theme is used

    6. Template: It is the parent theme name folder. In this case, that would always be Divi - case sensitive.

  3. In the divi-child folder, create a second file and name it functions.php

  4. Place the following PHP code inside the functions.php file:

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

  5. Zip the entire folder, which should contain the two files: style.css and functions.php

  6. Go back to your WordPress Dashboard → Appearance → Themes

  7. Click on the Add New Theme button

  8. Click on the Upload Theme button

  9. Choose the zip file from Step 5

  10. Click on the Install Now button

  11. Activate the new Child theme

Pro Tip: you can download a ready-to-use Divi Child theme from this GitHub page.

Did this answer your question?