Back to knowledgebase

Create a Child Theme for WordPress

A child theme lets you customise a WordPress theme without editing the parent theme files directly.

This is useful if you need to make code-level changes to a classic WordPress theme. If your site uses a modern block theme, you may be able to make the change from the WordPress Site Editor instead.

You should only create a child theme if you are comfortable editing files and PHP. Take a backup before making changes.

  1. Connect to your hosting account using FTP or cPanel File Manager.
  2. Open the WordPress theme folder:

/wp-content/themes/

  1. Create a new folder for the child theme.

A common naming style is to use the parent theme folder name followed by -child. For example:

twentytwentyfive-child

  1. Inside the new child theme folder, create a file called style.css.
  2. Add a theme header to the top of the file.

Example:

/*
Theme Name: Twenty Twenty-Five Child
Template: twentytwentyfive
Version: 1.0.0
*/

The Template value must match the folder name of the parent theme exactly.

  1. Save the style.css file.
  2. Create a second file in the child theme folder called functions.php.
  3. Add the code needed to load the parent theme stylesheet.

Example:

<?php
add_action( 'wp_enqueue_scripts', 'child_theme_enqueue_styles' );

function child_theme_enqueue_styles() {
    wp_enqueue_style(
        'parent-style',
        get_template_directory_uri() . '/style.css'
    );
}
  1. Save the functions.php file.
  2. Log in to WordPress.
  3. Go to Appearance > Themes.
  4. Activate the child theme.

After activating the child theme, check the site carefully. If the design changes unexpectedly, switch back to the parent theme and review the child theme files.

Some parent themes load more than one stylesheet or use their own method for loading styles. In those cases, this basic example may need adjusting by a developer.