What a child theme is and why you need one
A child theme is a WordPress theme that inherits the design and functionality of another theme — called the parent theme — while letting you make your own changes without touching the parent files. When you update the parent theme, your changes stay intact because they live in a separate folder.
If you edit the parent theme directly and then update it, WordPress overwrites all your customizations. A child theme prevents this. You can modify colors, fonts, layouts, and add custom code while keeping the parent theme untouched and updatable.
Most WordPress users who want to customize beyond what the theme settings allow should use a child theme. It takes about 15 minutes to set up and requires only two files.
Key Takeaways
- A child theme lives in its own folder and inherits everything from the parent theme, so your changes survive parent theme updates.
- You need only two files to create a working child theme: a folder, a style.css file, and a functions.php file.
- The style.css file must include a specific header comment that tells WordPress which theme is the parent.
- After creating the child theme files, you activate it in WordPress the same way you activate any other theme.
- Use the child theme's functions.php to add custom code, and its style.css to override parent theme styles.
Create the child theme folder and files
Connect to your site using an FTP client like FileZilla or use the File Manager in your hosting control panel. Navigate to /wp-content/themes/. This is where WordPress stores all themes.
Create a new folder and name it something clear, like parentthemename-child. If your parent theme is called "Astra", name the folder astra-child. This naming makes it obvious which parent theme the child belongs to.
Inside that folder, create two empty text files. Name the first one style.css and the second one functions.php. You now have the minimum structure needed. Do not skip either file — both are required for WordPress to recognize the child theme.
Write the style.css header
Open style.css in a text editor (Notepad, VS Code, or any plain-text editor works). At the very top, paste this code block exactly as shown:
/* Theme Name: Astra Child Description: Child theme for Astra Template: astra Version: 1.0 Text Domain: astra-child Domain Path: /languages */
Replace "Astra" with your actual parent theme name in both the Theme Name and Description lines. Replace "astra" in the Template line with the exact folder name of your parent theme — this is the critical line that tells WordPress which theme is the parent. The Template value must match the parent theme's folder name exactly, or WordPress will not recognize the child theme.
After this header block, you can add your own CSS rules. Any styles you write here will override the parent theme's styles. Save the file.
Set up the functions.php file
Open functions.php in your text editor and paste this code:
<?php function astra_child_enqueue_styles() { wp_enqueue_style( 'astra-child-style', get_stylesheet_uri() ); } add_action( 'wp_enqueue_scripts', 'astra_child_enqueue_styles' );
This code tells WordPress to load your child theme's style.css file. Without it, your CSS changes may not appear. Replace "astra-child" with your child theme's folder name (use hyphens, not spaces).
If you want to add custom PHP code later — like custom functions or hooks — add it below this block. Save the file when you are done.
Upload the files and activate the child theme
Upload both style.css and functions.php to your child theme folder using FTP or File Manager. Make sure they are in the correct folder: /wp-content/themes/yourchildthemename/.
Log into your WordPress dashboard. Go to Appearance → Themes. You should see your child theme listed. Click Activate. WordPress now loads your child theme instead of the parent theme.
Visit your site's front end to confirm it still looks correct. If something looks broken, the most common cause is a typo in the Template line of style.css — it must match the parent theme folder name exactly.
Add your customizations to the child theme
Now that the child theme is active, you can customize it without affecting the parent theme. Add CSS rules to style.css to change colors, fonts, spacing, or layouts. For example, to change the main heading color to blue, add this to style.css:
h1 { color: blue; }
To override a specific parent theme style, you may need to use the same CSS selector the parent uses. Inspect the parent theme's style.css file to see what selectors it uses, then write your own rules with the same selectors in the child theme's style.css — your rules will take priority.
For custom PHP functions, add them to functions.php below the enqueue code. For custom page templates or other files, create them in the child theme folder and they will be used instead of the parent theme's versions.
Common mistakes to avoid
The Template line in style.css is the most frequent source of errors. It must be the exact folder name of the parent theme, in lowercase, with hyphens instead of spaces. If you are unsure of the exact name, open the parent theme's style.css file and look at its Theme Name — then convert it to lowercase with hyphens. For "Astra Pro", the folder is "astra-pro" and the Template line should read Template: astra-pro.
Do not edit the parent theme's files directly. If you need to override a parent file, copy it to the child theme folder and edit the copy. WordPress will use the child version automatically.
If you add custom code to functions.php and your site breaks, you can temporarily deactivate the child theme from the Themes page to get your site working again, then fix the code and reactivate it.
Frequently Asked Questions
What happens to my child theme when I update the parent theme?
Your child theme files stay exactly as they are. The parent theme updates, but your customizations in the child theme folder are not touched. This is the entire point of using a child theme — your changes survive updates.
Can I use a child theme with any WordPress theme?
Yes. Any theme can be a parent theme. The parent theme does not need to be specially designed for child themes — the child theme system is built into WordPress itself.
Do I need to know code to create a child theme?
No. The basic setup requires only copying the header block into style.css and the enqueue code into functions.php — both are provided above. If you only want to change colors and fonts, you only need CSS, which is simpler than full programming.
What if my child theme does not show up in the Themes list?
The most common cause is a missing or incorrect Template line in style.css. Check that the Template value matches the parent theme's folder name exactly, including capitalization and hyphens. Also confirm that both style.css and functions.php are in the child theme folder, not in a subfolder.
Can I create a child theme of a child theme?
Technically yes, but it is not recommended. A grandchild theme makes updates and troubleshooting harder. Create your child theme from the original parent theme instead.