Skip to content

How to create a child theme ​

If you plan to change your theme's code, WordPress recommends protecting your work with a child theme. Any changes you make directly to a theme are likely to be overwritten when you update it. A child theme lets you copy the theme's files and tweak them without worrying about future theme updates overwriting your changes.

In this article

Before You Start ​

Creating a child theme to change the theme's functionality is intended for developers only. Creating one without a specific reason is not recommended, because it is a customization and is not covered by the support service - more details here.

Are you using Hestia? Check out how to create a child theme for Hestia.

Are you using Neve? Check out how to create a child theme for Neve.

You need one folder, a stylesheet and a functions file. Make sure you have FTP access to your site before you continue.

You can also follow along with the video tutorial on YouTube.

Instructions ​

This example creates a child theme of Zelle Pro.

  1. Log in to your website with an FTP client, such as FileZilla, and go to the wp-content/themes/ directory. This is the directory where all your themes are stored.

  2. Create a new folder for your child theme. You can give it any name; this example uses zelle-pro-child.

  3. Inside that folder, create a style.css file. Open it in a text editor and paste the following information into it:

    /*
       Theme Name: Zelle Pro Child
       Theme URI: https://www.themeisle.com/
       Description: This is a custom child theme I have created.
       Author: ThemeIsle
       URI: https://www.themeisle.com/
       Template: zerif-pro
       Version: 0.1
       */
  4. Load the parent theme's stylesheet. Create a file named functions.php in the child theme folder, open it, and paste the following:

    <?php
    add_action( 'wp_enqueue_scripts', 'child_enqueue_styles',99);
    function child_enqueue_styles() {
        $parent_style = 'parent-style';
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) );
    }
    if ( get_stylesheet() !== get_template() ) {
        add_filter( 'pre_update_option_theme_mods_' . get_stylesheet(), function ( $value, $old_value ) {
             update_option( 'theme_mods_' . get_template(), $value );
             return $old_value; // prevent update to child theme mods
        }, 10, 2 );
        add_filter( 'pre_option_theme_mods_' . get_stylesheet(), function ( $default ) {
            return get_option( 'theme_mods_' . get_template(), $default );
        } );
    }
  5. Save all changes.

  6. In your WordPress dashboard, go to Appearance > Themes and activate the new child theme.

📝 Note: If you are creating a child theme for a different theme, replace Template: zerif-pro in style.css with the folder name of your theme, for example Template: neve.

Keeping Your Customizer Changes ​

If you already made changes to your parent theme in the Customizer, they probably won't appear after you activate your child theme. To bring them over, use the Customizer Export Import plugin.

Having difficulties? Contact Themeisle support.

Was this helpful?