How to set up child themes on WordPress
A child theme is a WordPress theme that inherits functionality from a parent theme, allowing you to make customizations without losing changes when the parent theme updates. Setting up a child theme involves creating a new folder in your themes directory with a style.css file and functions.php file.
Prerequisites
- Active WordPress installation
- Access to WordPress admin dashboard
- Basic understanding of themes
- File manager or FTP access (optional)
Step-by-Step Instructions
Access your WordPress themes directory
/wp-content/themes/ folder. You can access this through your hosting control panel's File Manager, FTP client, or WordPress admin dashboard using Appearance > Theme Editor (though file manager is recommended for safety).Create a new child theme folder
/wp-content/themes/ directory, create a new folder for your child theme. Name it using your parent theme's name followed by -child. For example, if your parent theme is Twenty Twenty-Four, name the folder twentytwentyfour-child.Create the style.css file
style.css. Add the following header information at the top:/*
Theme Name: Twenty Twenty-Four Child
Description: Child theme of Twenty Twenty-Four
Template: twentytwentyfour
Version: 1.0
*/Replace the theme names and template value with your actual parent theme information. The Template value must exactly match your parent theme's folder name.
Create the functions.php file
functions.php file in your child theme folder and add the following code to properly enqueue the parent theme's stylesheet:function child_theme_enqueue_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'child_theme_enqueue_styles');Activate your child theme
Verify the child theme is working
Start customizing your child theme
style.css file or add custom functions to functions.php. To override parent theme template files, copy them from the parent theme folder to your child theme folder and modify as needed.Common Issues & Troubleshooting
Child theme not appearing in Appearance > Themes
Check that your style.css file has the correct header format and is saved in the proper child theme folder. Ensure the folder is located in /wp-content/themes/.
Site looks broken after activating child theme
Verify your functions.php file properly enqueues the parent stylesheet. Check that the Template value in style.css exactly matches your parent theme's folder name.
Parent theme styles not loading
Ensure your functions.php file uses wp_enqueue_style() to load the parent theme's CSS. Check for any PHP syntax errors that might prevent the file from executing properly.
Changes not appearing on frontend
Clear any caching plugins or browser cache. Verify you're editing files in the child theme folder, not the parent theme. Check that your child theme is actually activated in Appearance > Themes.