Paramclasses Academy - Blog

Tutorials Details

←
Post 33 of 40
→

What is WordPress Child Theme: Customize a Theme Safely ?

What is WordPress Child Theme: Customize a Theme Safely ?

November 17, 2026

1. Introduction

When developing a WordPress website, you may want to customize the theme's design, layout, colors, typography, or functionality.

For example, you may want to:

  • Change the website's heading colors.

  • Add custom CSS.

  • Modify the header or footer.

  • Add custom PHP functions.

  • Customize a page template.

  • Add additional website functionality.

You could directly edit your parent theme's files, but this creates a serious problem.

When the parent theme receives an update, your direct modifications may be overwritten.

The professional solution is to create a Child Theme.

A child theme allows you to customize an existing WordPress theme without directly modifying the original parent theme files.

In this tutorial, you will learn how to create, install, activate, and customize a WordPress child theme step by step.

2. What Is a WordPress Child Theme?

A WordPress child theme is a theme that inherits the design and functionality of another theme, known as the parent theme.

The parent theme provides the original website structure, while the child theme allows you to add your own customizations.

For example:

WordPress Website
│
└── wp-content/
    │
    └── themes/
        │
        ├── astra/
        │   ├── style.css
        │   ├── functions.php
        │   └── template files
        │
        └── astra-child/
            ├── style.css
            ├── functions.php
            └── screenshot.png

In this example:

  • astra is the parent theme.

  • astra-child is the child theme.

  • The child theme inherits the parent theme's functionality and design.

  • Custom code can be maintained separately inside the child theme.

The parent theme folder and child theme folder must remain separate.

Learn more from the official WordPress Child Themes Handbook.

3. Why Should You Use a Child Theme?

There are several advantages to using a child theme.

A. Protect Customizations During Updates

Suppose you modify the parent theme's style.css file directly.

After a theme update, the original stylesheet may replace your modifications.

With a child theme, your custom CSS is stored separately and is not normally overwritten by parent theme updates.

B. Safe Theme Customization

You can add your own CSS, PHP functions, and supported template overrides without editing the original parent theme files.

C. Easy Maintenance

Your customizations remain organized in a separate directory.

This makes it easier to identify, update, and troubleshoot your custom code.

D. Better Development Practice

Child themes are useful for learning WordPress theme development and building custom website designs.

Important: A child theme protects your custom files from normal parent theme updates. It does not guarantee that every customization will remain compatible with every future parent theme version.

4. Parent Theme vs Child Theme

A parent theme is the original, complete WordPress theme.

A child theme is an extension of that theme.

For example:

Parent Theme:
Astra

Child Theme:
Astra Child

The parent theme provides the main design and functionality.

The child theme provides your additional customizations.

WordPress loads both themes when the child theme is active, but their files are handled differently:

  • The child theme's functions.php runs before the parent's functions.php.

  • The child theme's matching template files can override corresponding parent templates.

  • The child theme's stylesheet can add or override CSS when properly loaded.

  • Files that are not overridden continue to come from the parent theme.

A child theme does not replace the parent theme's entire functionality.

5. Requirements Before Creating a Child Theme

Before starting, make sure you have:

  • A working WordPress website.

  • An installed parent theme.

  • Access to your hosting File Manager or FTP/SFTP.

  • A code editor such as Visual Studio Code.

  • Basic knowledge of HTML, CSS, and PHP.

  • A recent website backup.

For practice, you can use a local WordPress installation created with XAMPP.

For this tutorial, we will use Astra as an example parent theme.

You can use another theme, but you must use its actual folder name in the child theme configuration.

6. Understand the Important Child Theme Files

A basic child theme requires a directory and a style.css file with the correct theme header.

A functions.php file is commonly added to load styles and register custom functionality.

Let's understand these files.

A. style.css

The style.css file contains the child theme's header information and can also contain custom CSS.

Example:

/*
Theme Name: Astra Child
Description: Custom child theme for Astra
Author: Param Classes
Version: 1.0.0
Template: astra
*/

/* Custom CSS starts here */

Important fields:

  • Theme Name: The name displayed in the WordPress dashboard.

  • Description: A short description of your child theme.

  • Author: The theme developer.

  • Version: The child theme version.

  • Template: The exact parent theme folder name.

Most important: The Template value must match the parent theme's directory name exactly.

For example, if the parent folder is:

wp-content/themes/astra/

Then the child theme header must contain:

Template: astra

If the folder is named differently, WordPress may not recognize the child theme correctly.

Official reference: WordPress Main Stylesheet Documentation.

B. functions.php

The functions.php file is used to add custom PHP functionality to your theme.

For example, you can use it to:

  • Enqueue stylesheets and scripts.

  • Register theme features.

  • Add custom hooks.

  • Modify selected WordPress behavior.

  • Include additional PHP files.

Unlike template files, a child theme's functions.php does not replace the parent theme's functions.php.

Both files are loaded.

Official reference: WordPress Custom Functionality.

C. screenshot.png

The screenshot.png file is an optional preview image for your child theme.

WordPress can display this image in the Appearance → Themes section.

A typical theme preview image is 1200 × 900 pixels.

7. Method 1: Create a Child Theme Manually Using XAMPP

Now we will create our first child theme manually.

Step 1: Open Your WordPress Project

If you are using XAMPP:

  1. Start Apache and MySQL.

  2. Open your WordPress project directory.

  3. Navigate to:

C:\xampp\htdocs\your-project\wp-content\themes\
  1. Inside the themes directory, find your installed parent theme.

For example:

themes/
│
├── astra/
├── twentytwentyfive/
└── other-theme/

Make sure Astra is installed before creating the Astra child theme.

Step 2: Create a Child Theme Folder

Inside the themes directory, create a new folder:

astra-child

Your directory should now look like this:

themes/
│
├── astra/
│
└── astra-child/

The astra-child folder will contain your customizations.

Step 3: Create style.css

Open Visual Studio Code.

  1. Select File → Open Folder.

  2. Open the astra-child directory.

  3. Create a new file named style.css.

  4. Add the following code:

/*
Theme Name: Astra Child
Description: Custom child theme for Astra
Author: Param Classes
Version: 1.0.0
Template: astra
*/

/* Website customization */

body {
    background-color: #f8fafc;
}

h1,
h2,
h3 {
    color: #172554;
}

a {
    color: #ea580c;
}

Save the file.

This example changes the background, heading colors, and link color.

The CSS will take effect only when the child stylesheet is loaded and the selectors are not overridden by stronger theme styles.

Step 4: Create functions.php

Inside the same astra-child folder:

  1. Create a new file.

  2. Name it functions.php.

  3. Add this code:

<?php

/**
 * Load the parent and child stylesheets.
 */

function param_astra_child_enqueue_styles() {

    wp_enqueue_style(
        'param-astra-parent-style',
        get_parent_theme_file_uri( 'style.css' ),
        array(),
        wp_get_theme( get_template() )->get( 'Version' )
    );

    wp_enqueue_style(
        'param-astra-child-style',
        get_stylesheet_uri(),
        array( 'param-astra-parent-style' ),
        wp_get_theme()->get( 'Version' )
    );

}

add_action(
    'wp_enqueue_scripts',
    'param_astra_child_enqueue_styles'
);

Save the file.

Let's understand the important functions.

wp_enqueue_style()

This WordPress function registers and loads a CSS stylesheet.

get_parent_theme_file_uri()

It retrieves the URL of a file from the parent theme.

get_stylesheet_uri()

It returns the active theme's stylesheet URL. When the child theme is active, this points to the child theme's style.css.

wp_get_theme()

It retrieves theme information, including its version.

add_action()

It connects a custom function to a WordPress action hook.

wp_enqueue_scripts

This hook is used to enqueue frontend stylesheets and scripts.

The example above is suitable for a parent theme whose stylesheet is not already being loaded in a way that includes the required parent CSS.

Before using it with another parent theme, inspect how that theme loads its styles. Some themes already load both parent and child stylesheets, while others use a different stylesheet handle or loading method. Avoid loading the parent stylesheet twice.

Official reference: WordPress Including Assets.

Step 5: Create the Optional Theme Screenshot

Inside the astra-child folder, add a preview image named:

screenshot.png

Example folder structure:

astra-child/
│
├── style.css
├── functions.php
└── screenshot.png

The screenshot is optional, but it helps identify the child theme in the WordPress dashboard.

Step 6: Verify the Final Folder Structure

Your completed child theme should look like this:

wp-content/
│
└── themes/
    │
    ├── astra/
    │   ├── style.css
    │   ├── functions.php
    │   └── other theme files
    │
    └── astra-child/
        │
        ├── style.css
        ├── functions.php
        └── screenshot.png

Check these points:

  • The child theme folder is inside wp-content/themes.

  • The style.css file is present.

  • The Template field contains the exact parent folder name.

  • The PHP file has no syntax errors.

  • The parent theme is installed.

8. Activate the Child Theme in WordPress

Now our child theme is ready.

Let's activate it.

Step 1: Open WordPress Dashboard

Open your WordPress administrator area:

http://localhost/your-project/wp-admin

Enter your login credentials.

Step 2: Open Themes

Navigate to:

Appearance → Themes

You should see the newly created Astra Child theme.

Step 3: Activate the Child Theme

  1. Locate Astra Child.

  2. Click its Activate button.

  3. Wait for WordPress to activate the theme.

Your child theme is now active.

The website should continue using the parent theme's design, with your child theme customizations applied where supported.

Step 4: Preview the Website

Open the frontend:

http://localhost/your-project/

Check whether:

  • The website loads correctly.

  • The parent theme design is visible.

  • Your custom background color is applied.

  • Your heading colors are visible.

  • Your links use the custom color.

If the website looks different from the expected result, inspect the stylesheet loading order and browser developer tools.

9. Method 2: Create a Child Theme Using cPanel

You can also create a child theme on live hosting using cPanel.

Follow these steps:

Step 1: Log in to cPanel

  1. Open your hosting account.

  2. Log in to cPanel.

  3. Open File Manager.

Step 2: Open the Themes Directory

Navigate to:

public_html/wp-content/themes/

If your WordPress installation is inside another folder or uses a different document root, open that installation's actual themes directory.

Step 3: Create a New Folder

  1. Click + Folder.

  2. Enter the folder name:

astra-child
  1. Click Create New Folder.

Step 4: Create style.css

  1. Open the astra-child directory.

  2. Click + File.

  3. Enter style.css.

  4. Open the file in the editor.

  5. Add the child theme header and your CSS code.

  6. Save the file.

Step 5: Create functions.php

  1. Create another file named functions.php.

  2. Add the stylesheet enqueue code from Section 7, after checking the parent theme's stylesheet behavior.

  3. Save the file.

Step 6: Activate the Theme

Open the WordPress dashboard.

Navigate to:

Appearance → Themes

Activate Astra Child.

Always create a backup before editing files on a live website.

10. Customize the Website Using Child Theme CSS

Now let's perform some practical customizations.

Open:

astra-child/style.css

Add the following CSS below the theme header.

Example 1: Change Website Background

body {
    background-color: #f1f5f9;
}

Example 2: Customize Headings

h1,
h2,
h3 {
    color: #1e293b;
    font-weight: 700;
}

Example 3: Customize Buttons

button,
input[type="submit"],
.wp-block-button__link {
    background-color: #ea580c;
    color: #ffffff;
    border-radius: 8px;
    padding: 12px 24px;
}

Example 4: Add Hover Effects

a {
    transition: color 0.3s ease;
}

a:hover {
    color: #c2410c;
}

Save the file and refresh the website.

If you do not see the changes, clear the website cache and browser cache. Also check whether the theme uses more specific CSS selectors.

11. Add Custom PHP Functionality Using functions.php

A child theme is not limited to CSS customization.

You can also add PHP functionality.

Let's understand a simple example.

Example: Add a Custom Footer Message

Open:

astra-child/functions.php

Add this code:

<?php

function param_custom_footer_message() {

    echo '<p class="param-footer-message">
        Website developed with WordPress.
    </p>';

}

add_action(
    'wp_footer',
    'param_custom_footer_message'
);

This code creates a custom function and connects it to the wp_footer action hook.

When WordPress executes the footer hook, the message is printed.

You can style the message using your child theme's style.css:

.param-footer-message {
    text-align: center;
    color: #64748b;
    font-size: 14px;
    padding: 15px;
}

Important: The wp_footer hook is available only if the active theme properly calls wp_footer() in its footer template. This example adds a message but does not replace the theme's existing footer.

For reusable functionality that should remain active even when changing themes, consider creating a custom plugin instead of putting that functionality in the theme.

12. Override a Parent Theme Template

One of the important features of a child theme is the ability to override supported parent theme templates.

Suppose the parent theme contains:

astra/
│
├── header.php
├── footer.php
├── single.php
└── page.php

If you want to customize a supported template such as footer.php, you can create a file with the same relative path in the child theme:

astra-child/
│
└── footer.php

WordPress can use the child theme's matching template instead of the parent's version.

However, you must understand the following:

  • Copy only the template you need to customize.

  • Do not copy the parent's entire functions.php into the child theme.

  • Parent themes may use custom template-loading systems.

  • Some themes use hooks and template parts rather than traditional PHP templates.

  • Block themes use block templates and template parts, which follow a different structure.

For block themes, child themes can contain files such as:

my-child-theme/
│
├── style.css
├── theme.json
├── functions.php
│
├── templates/
│   └── single.html
│
└── parts/
    └── footer.html

The child theme can override supported block templates and template parts by using the appropriate filenames and directory structure.

Learn more in the WordPress Child Theme Handbook.

13. Important Difference Between Classic Themes and Block Themes

WordPress themes generally fall into two broad categories.

A. Classic Themes

Classic themes commonly use PHP template files.

Examples include:

  • header.php

  • footer.php

  • single.php

  • page.php

  • functions.php

  • style.css

For these themes, child themes are commonly used for PHP template overrides, CSS, and custom functions.

B. Block Themes

Block themes use the WordPress block system and Site Editor.

Their structure may include:

  • theme.json

  • templates/

  • parts/

  • patterns/

  • styles/

You can create a child block theme to customize templates, template parts, global styles, and other theme files.

For many block-theme design changes, the Site Editor already stores user customizations in the database. You may not need a child theme for every visual adjustment.

If you want to distribute or maintain those changes as theme files, a child block theme may be more suitable.

Official reference: WordPress Theme Developer Handbook.

14. Common Child Theme Mistakes

Mistake 1: Incorrect Template Name

Incorrect:

Template: Astra

Correct:

Template: astra

The value must match the parent theme folder name exactly.

Mistake 2: Missing style.css

WordPress needs the child theme's style.css file with a valid theme header to recognize it.

Check the filename and directory location.

Mistake 3: Incorrect functions.php Syntax

Incorrect PHP syntax can cause a fatal error.

Always test your PHP code on localhost or staging before applying it to a live website.

Mistake 4: Parent Stylesheet Not Loading

Sometimes the child theme is active, but the parent theme's CSS is not loaded correctly.

Check the parent's enqueue code and follow the correct stylesheet dependency approach.

Do not blindly add multiple stylesheet enqueue functions.

Mistake 5: Editing Parent Theme Files

Do not place your custom code directly inside the parent theme's files if you want to preserve it across updates.

Use the child theme or an appropriate plugin.

Mistake 6: Copying the Entire Parent functions.php

The parent and child functions.php files are both loaded.

Copying the parent's functions into the child can cause duplicate function declarations and fatal errors.

Add only the custom functionality you need.

Mistake 7: Forgetting Website Backups

A syntax error in a PHP file can make the website unavailable.

Keep a backup and maintain access to File Manager or SFTP so you can repair the file if the dashboard becomes inaccessible.

15. Best Practices for WordPress Child Themes

Follow these professional development practices:

  1. Always create a backup before changing theme files.

  2. Use a child theme for customizations that need to survive parent theme updates.

  3. Use unique prefixes for custom PHP functions.

  4. Follow WordPress coding standards.

  5. Enqueue CSS and JavaScript using WordPress functions.

  6. Avoid editing parent theme files directly.

  7. Test updates on staging before applying them to production.

  8. Avoid unnecessary template overrides.

  9. Keep custom code organized and documented.

  10. Use a custom plugin for functionality that should survive theme changes.

  11. Check parent theme documentation before overriding templates.

  12. Keep your child theme compatible with the parent theme's updates.

For coding standards, see the official WordPress Coding Standards.

16. Practical Assignment

Now create your own child theme as a practical project.

Task 1: Install a Parent Theme

  1. Install the Astra theme.

  2. Activate it once to confirm that it works.

  3. Identify its theme directory.

Task 2: Create a Child Theme

  1. Open the themes directory.

  2. Create an astra-child folder.

  3. Create style.css.

  4. Add the correct theme header.

  5. Create functions.php.

  6. Add the stylesheet enqueue code after checking the parent theme's stylesheet setup.

Task 3: Activate Your Child Theme

  1. Open WordPress Dashboard.

  2. Navigate to Appearance → Themes.

  3. Activate Astra Child.

  4. Open your website frontend.

Task 4: Customize the Website

Add these changes:

  • Change the website background color.

  • Change heading colors.

  • Customize button design.

  • Add a hover effect to links.

  • Add a custom footer message using PHP.

Task 5: Test Your Customization

  1. Refresh your website.

  2. Check desktop and mobile layouts.

  3. Confirm that the parent theme design remains functional.

  4. Review your PHP and CSS for errors.

  5. Create a backup of the completed child theme.

Expected result: You should have a working Astra Child theme with custom CSS and PHP functionality, without modifying the original parent theme files.

17. Frequently Asked Questions

Q1. What is a WordPress child theme?

A child theme is an extension of an existing parent theme. It allows developers to customize the design and functionality without directly modifying the parent theme files.

Q2. Is a child theme necessary for every WordPress website?

No. A child theme is useful when you need code-based customizations that should remain separate from the parent theme. Simple visual changes can often be handled through the Customizer or Site Editor.

Q3. Will parent theme updates delete my child theme?

Normal parent theme updates do not overwrite the separate child theme directory. However, changes in the parent theme can sometimes affect compatibility.

Q4. Can I create a child theme without coding?

Yes. You can use a suitable child theme generator or a plugin, depending on the parent theme and available tools. However, understanding the files and configuration is important for developers.

Q5. What is the purpose of the Template field in style.css?

The Template field identifies the parent theme directory. WordPress uses it to connect the child theme to the correct parent theme.

Q6. Can a child theme have its own functions.php file?

Yes. The child theme can have its own functions.php. WordPress loads the child theme's file before the parent theme's file. It does not replace the parent file.

Q7. Can I use a child theme with Elementor?

Yes. Elementor can work with compatible parent and child themes. The child theme is useful when you need custom PHP, CSS, or template-level changes outside Elementor's visual editing features.

Q8. Can I delete the parent theme after activating the child theme?

No. The parent theme is required because the child theme inherits its design and functionality from it.

Q9. Is a child theme suitable for WooCommerce websites?

Yes. A child theme can be used for supported WooCommerce template customizations and styling. However, template overrides should be checked against WooCommerce updates because outdated overrides may become incompatible.

Q10. Does a child theme protect customizations from every update?

It protects custom code stored in the child theme from being overwritten by normal parent theme updates. It does not guarantee that customizations will always work with future versions.

18. Conclusion

A WordPress child theme is an important tool for developers who want to customize an existing theme safely.

In this tutorial, you learned how to:

  • Understand parent and child themes.

  • Create a child theme manually.

  • Configure the style.css file.

  • Create and configure functions.php.

  • Load parent and child stylesheets.

  • Activate a child theme.

  • Add custom CSS and PHP functionality.

  • Override supported parent templates.

  • Understand classic and block theme differences.

  • Follow professional child theme development practices.

Final takeaway: Never depend on direct parent theme file modifications for customizations that must survive theme updates. Use a child theme or an appropriate custom plugin to keep your code maintainable.

←
Post 33 of 40
→