How To Create A Child Theme In WordPress

Here is an article on how to create a child theme in WordPress. This method ensures that your customizations (like CSS, PHP functions, and templates) are safe from being overwritten when the parent theme updates.

What Is a Child Theme?

A child theme is a WordPress theme that inherits the functionality and styling of another theme, called the parent theme. You can use it to:

  • Add custom CSS
  • Modify templates
  • Extend functionality with PHP …without touching the original parent theme files.

Before you start, make sure:

  • You have access to your site files via FTP, hosting file manager, or local WordPress installation.
  • You know the parent theme name you want to base your child theme on (e.g., twentytwentyfour).

Step 1: Navigate to Your Themes Directory

  1. Log into your server using FTP (like FileZilla), File Manager (e.g., in cPanel), or a local development tool.

Go to:
/wp-content/themes/

Step 2: Create a New Folder for the Child Theme

  1. Inside /themes/, create a new folder.

Name it something like:
twentytwentyfour-childtheme

  1.  Use a consistent format: parent-theme-name-child

Step 3: Create style.css in Your Child Theme Folder

Inside the child theme folder, create a file named:
style.css

  1. Add the following to it:

/*

Theme Name: Twenty Twenty-Four Child

Theme URI: https://example.com/

Description: A child theme of Twenty Twenty-Four

Author: Your Name

Author URI: https://yourwebsite.com/

Template: twentytwentyfour

Version: 1.0

*/

/* Add custom CSS below */

body {

    background-color: #f7f7f7;

}

Important:

  • The Template: value must exactly match the parent theme’s folder name (case-sensitive).
  • The Theme Name: must be unique among installed themes.

Step 4: Create functions.php to Load Styles

In the same child theme folder, create:

functions.php

  1. Add this PHP code to it:

<?php

// Enqueue parent and child theme styles

function my_child_theme_enqueue_styles() {

    $parent_style = ‘twentytwentyfour-style’; // Change this if your parent theme uses a different handle

    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),

        wp_get_theme()->get(‘Version’)

    );

}

add_action(‘wp_enqueue_scripts’, ‘my_child_theme_enqueue_styles’);

If you’re unsure of the parent style handle, check its functions.php — search for wp_enqueue_style().

Step 5: Upload the Child Theme (If Created Locally)

If you created the child theme on your computer:

  1. Compress the folder into a .zip file.
  2. Go to WordPress Admin → Appearance → Themes → Add New → Upload Theme
  3. Upload and Activate your child theme.

Step 6: Activate the Child Theme

  1. Log in to your WordPress Admin Dashboard.
  2. Go to:
    • Appearance → Themes
  3. You’ll see your child theme listed.
  4. Click Activate.

Your site is now using the child theme.

Step 7: Test and Add More Customizations

  • Open your website and confirm everything looks and functions normally.
  • You can now add custom:
    • CSS → style.css
    • PHP → functions.php
    • Template overrides → e.g., header.php, page.php, etc.

Overriding a Template File

To override a parent template (e.g., header.php):

Copy the file from the parent theme:
/wp-content/themes/twentytwentyfour/header.php

Paste it into your child theme folder:
/wp-content/themes/twentytwentyfour-child/header.php

  1. Edit it as needed. WordPress will automatically use your version.

Similar Posts