If you edit a theme's files directly, the next theme update replaces them and your changes disappear. A child theme is a small theme that inherits everything from its parent and holds only your changes. The parent can then update safely.
Before you start
- Check whether you need one. Changes made in Appearance → Customize → Additional CSS, the Site Editor or a page builder are stored in the database and survive updates without a child theme.
- You need a child theme when you edit template files, add PHP to
functions.phpor override theme functions. - Note the parent theme's folder name in
wp-content/themes, for exampleastra. - Many commercial themes ship a ready-made child theme ZIP; use that if available.
Create the child theme folder
- Open cPanel → Files → File Manager and go to
wp-content/themes. - Click + Folder and create a folder such as
astra-child.
Add style.css
Inside the new folder create style.css with this header, changing the names:
/*
Theme Name: Astra Child
Template: astra
Version: 1.0
*/Template must match the parent's folder name exactly, including case. Your custom CSS goes below the header.
Add functions.php
Create functions.php in the same folder to load the parent's styles and then your own:
<?php
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ), wp_get_theme()->get( 'Version' ) );
} );Some modern themes load their stylesheet themselves; if styles appear twice, remove the parent line.
Activate the child theme
- In WordPress go to Appearance → Themes.
- Find your child theme and click Activate.
- Visit the site. It should look exactly like before.
- Check Appearance → Customize: some theme settings are stored per theme, so you may need to set menus, logo and widgets again or use the theme's import/export option.
Move your changes over
- CSS: add to the child's
style.css, or keep it in Additional CSS. - Template files: copy the file from the parent (for example
footer.php) into the same relative path in the child and edit the copy. WordPress uses the child's version first. - PHP functions: add to the child's
functions.php. Unlike templates, the parent'sfunctions.phpstill loads too.
Keep it maintained
- When the parent theme changes a template you copied, compare and merge changes; the theme's changelog usually mentions template updates.
- Bump the child's
Versionafter CSS edits so browsers and LiteSpeed load the new file. - Keep the child theme in version control or a backup.
Troubleshooting
- "The parent theme is missing": the
Templatevalue does not match the parent folder name. - Site looks unstyled: the parent stylesheet is not enqueued; check
functions.php. - White screen after editing functions.php: a PHP syntax error. Rename the child folder to fall back to another theme, fix the file, then rename it back.
- CSS changes not visible: purge LiteSpeed Cache and increase the version number.
