Child themes let you change a WordPress site's look or features without changing the original theme. This keeps your changes safe when the original theme updates.
Child themes and overrides in Wordpress
/* style.css in child theme folder */ /* Theme Name: My Child Theme Template: parent-theme-folder-name */ @import url("../parent-theme-folder-name/style.css"); /* Your custom styles here */
The Template line must exactly match the parent theme folder name.
Use @import to load the parent theme's styles before adding your own.
/* style.css in child theme */ /* Theme Name: Simple Child Template: twentytwentyone */ @import url("../twentytwentyone/style.css"); body { background-color: #f0f0f0; }
<?php // functions.php in child theme add_action('wp_enqueue_scripts', function() { wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css'); wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style')); });
This child theme changes the link color to red while keeping all other styles and features from the parent theme.
/* style.css in child theme folder */ /* Theme Name: Custom Child Template: twentytwentyone */ @import url("../twentytwentyone/style.css"); /* Change link color */ a { color: #e63946; }
Always use a child theme to keep your changes safe during parent theme updates.
Do not edit parent theme files directly; your changes will be lost on update.
Use the functions.php in the child theme to add or override PHP functions safely.
Child themes let you customize a WordPress theme without changing the original files.
Use a style.css with a Template line to link to the parent theme.
Load parent styles properly using @import or wp_enqueue_style in functions.php.
Practice
Solution
Step 1: Understand child theme purpose
A child theme allows changes without touching the original theme files, preserving updates.Step 2: Compare options
Options A, C, and D describe unrelated or incorrect uses of child themes.Final Answer:
To customize a theme without modifying the original parent theme files -> Option AQuick Check:
Child theme purpose = Customize safely [OK]
- Thinking child themes replace parent themes
- Believing child themes delete parent themes
- Assuming child themes speed up the site
style.css to link it to its parent theme?Solution
Step 1: Identify correct header line
The child theme'sstyle.cssmust have aTemplateline naming the parent theme folder.Step 2: Eliminate wrong options
Options A, B, and D use incorrect keywords not recognized by WordPress.Final Answer:
Template: parent-theme-folder-name -> Option AQuick Check:
Child theme links parent with Template line [OK]
- Using 'Parent' instead of 'Template'
- Confusing 'Theme' or 'Import' as header lines
- Omitting the Template line entirely
functions.php snippet in a child theme, what will happen?<?php
function child_theme_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style'));
}
add_action('wp_enqueue_scripts', 'child_theme_styles');
?>Solution
Step 1: Analyze enqueue order
The parent style is enqueued first, then the child style with parent as dependency.Step 2: Understand effect on styles
This ensures parent styles load first, then child styles override them if needed.Final Answer:
Both parent and child styles load correctly, child overrides parent -> Option DQuick Check:
Proper enqueue order = parent then child [OK]
- Forgetting to enqueue parent style
- Loading child style before parent
- Not setting dependency array
Solution
Step 1: Check theme activation
If the parent theme is active, child theme changes won't apply.Step 2: Review other options
Missing Template line causes child theme not to work, but usually disables child theme; folder placement is less critical; @import usage is unrelated to activation.Final Answer:
You activated the parent theme instead of the child theme -> Option BQuick Check:
Active theme must be child for overrides [OK]
- Not activating the child theme
- Misplacing child theme folder
- Confusing @import usage location
header.php file in your child theme. Which is the correct way to do this?Solution
Step 1: Understand override mechanism
WordPress loads template files from child theme first if they exist.Step 2: Apply correct override method
Copyingheader.phpto child theme and editing it overrides the parent's version.Step 3: Eliminate wrong options
Editing parent directly breaks update safety; naming differently or empty files won't override.Final Answer:
Copy header.php from parent theme to child theme folder and modify it there -> Option CQuick Check:
Child theme file overrides parent file [OK]
- Editing parent theme files directly
- Using different file names for overrides
- Leaving override files empty
Ready to prove it?
Pass the test and this pattern moves unknown
