How to Create a Child Theme in WordPress
A child theme in WordPress is a theme that inherits the functionality and styling of another theme, called the parent theme. Creating a child theme lets you safely customize your site without losing changes when the parent theme updates. Here’s how to create one step by step.
Step 1: Create a Child Theme Folder
- Use FTP or File Manager in your hosting control panel.
- Navigate to
wp-content/themes/. - Create a new folder for your child theme. Example:
mytheme-child.
Step 2: Create a style.css File
Inside the child theme folder, create a file named style.css with the following content:
/*
Theme Name: MyTheme Child
Theme URI: https://example.com/mytheme-child
Description: Child theme for MyTheme
Author: Your Name
Author URI: https://example.com
Template: mytheme
Version: 1.0.0
*/
/* Custom CSS starts here */
body {
background-color: #f9f9f9;
}
Important: The Template value must match the folder name of your parent theme (e.g., mytheme).
Step 3: Create a functions.php File
In the same folder, create a functions.php file to enqueue the parent and child styles:
<?php
function mytheme_child_enqueue_styles() {
// Enqueue parent theme stylesheet
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css'
);
// Enqueue child theme stylesheet
wp_enqueue_style(
'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}
add_action('wp_enqueue_scripts', 'mytheme_child_enqueue_styles');
Step 4: Activate the Child Theme
- Log in to your WordPress dashboard.
- Go to Appearance → Themes.
- You should see your new child theme listed.
- Click Activate.
Step 5: Customize Safely
- Add CSS rules in
style.css. - Copy template files (e.g.,
header.php) from the parent theme into the child theme folder and edit them as needed. - Write PHP functions in
functions.phpto extend or modify features.
Best Practices
- Only copy template files you plan to change—WordPress will use the parent theme’s files for everything else.
- Keep the child theme lightweight to ensure easy updates to the parent theme.
- Always test on a staging site before making major edits.
Summary
- Create a new folder in
wp-content/themes/for your child theme. - Add a
style.cssfile with the correct header and custom styles. - Create a
functions.phpto enqueue parent and child stylesheets. - Activate the child theme from the dashboard.
- Customize safely without losing changes during theme updates.
With a child theme, you can confidently personalize your WordPress site while keeping the parent theme fully updatable.
🎨 Want to learn more? Visit our WordPress Customization Hub for tips and advanced techniques.