1) Create the child theme folder

  • Go to /wp-content/themes/
  • Create a new folder named <parent-slug>-child

Example: if the parent theme folder is astra, make astra-child.

The parent slug must match the parent theme’s folder name, not its display name.


2) Add style.css (required)

Create /wp-content/themes/<parent-slug>-child/style.css with this header (edit values):

/*
 Theme Name: Astra Child
 Template: astra
 Text Domain: astra-child
 Description: Child theme for Astra
 Author: Your Name/Company
 Version: 1.0.0
*/

The Template: value must equal the parent theme’s folder (e.g., astra, hello-elementor, twentytwentyfive).


3) (Classic themes) Enqueue styles in functions.php

If your parent is a classic theme (most non-FSE themes), create /wp-content/themes/<parent-slug>-child/functions.php:

<?php
add_action( 'wp_enqueue_scripts', function () {
    // Load parent style first.
    wp_enqueue_style(
        'parent-style',
        get_template_directory_uri() . '/style.css',
        [],
        wp_get_theme( get_template() )->get( 'Version' )
    );

    // Then child style.
    wp_enqueue_style(
        'child-style',
        get_stylesheet_uri(),
        [ 'parent-style' ],
        wp_get_theme()->get( 'Version' )
    );
} );

Don’t use @import in CSS. Always enqueue.


4) Activate the child theme

  • In wp-admin → Appearance → Themes
  • You should see “YourTheme Child” with your screenshot (optional). Activate it.

Optional: Add /screenshot.png (1200×900 px recommended) so it looks nice in the admin.


5) Customize safely

  • Classic themes: Copy only the template file you need from the parent into the child (keep the same relative path), then edit. Example: copy header.php → child theme header.php.
  • Put custom PHP (hooks/filters) in the child’s functions.php. Do not duplicate parent function names—use actions/filters instead.

Leave a Reply

Your email address will not be published. Required fields are marked *