Using a Child Theme

A child theme is a theme that uses the core “parent” theme files, unless one of those files (in the root directory of the parent theme) are copied and added to the child theme.

In that case, the copied file is used on your website so you can make changes to it without touching the parent theme.

This is useful as when updates are released for the parent theme, WordPress deletes the directory and uploads the new one. Any changes you made to the parent theme files are discarded and replaced with the newly updated files.

A child theme can also be used to add custom CSS and PHP in the style.css and functions.php files. These two files are the only child theme files that should be empty by default (don’t copy the parent files). However, if all you’ll be doing is adding CSS or PHP, a child theme probably isn’t necessary. See our Adding CSS and Adding PHP articles.

When using a child theme, GeneratePress will automatically enqueue the necessary style.css files. You don’t need to enqueue the parent or child theme CSS files in your functions.php file.

There are some common issues that people run into when creating a child theme which you can read about here.

Installing a child theme

If you’d like to download a completely blank starter child theme, click here.

To install the child theme, save it as a .zip file to your computer.

Then go to Appearance > Themes > Add New > Upload and upload the .zip file.

Will I lose my changes when I add a child theme?

If you’ve only used the theme options in the Customizer, you won’t lose any of your changes.

The only time you risk losing changes is when you make them to the parent theme files or use the Additional CSS field from WordPress.

It’s important to note that you may need to re-upload your logo (Customize > Site Identity) and re-add your Copyright (Customize > Layout > Footer) as these are stored in a theme-specific database option.

Avoid loading style.css of the child theme

If the child theme’s style.css file is empty and you’d like to avoid loading it, try this PHP snippet below:

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-child' );
}, 50 );

Using a child theme after importing a site library template

The site library templates are not child themes. Follow the steps below if you would like to use a child theme after importing a site library template:

  1. Copy the CSS that was imported in the Additional CSS field in the customizer of the parent theme.
  2. Install and activate a child theme using the instruction above.
  3. Paste the CSS from #1 to either: