Welcome to the next post in our WordPress Tips & Tricks series — created for beginners, DIY site owners, and developers who want to understand WordPress the right way. Today we’re diving into a topic that every WordPress user should master early – child theme in WordPress:
🚀 Why using a Child Theme is not optional — it’s mandatory for safe customization
If you edit your theme directly (CSS, PHP, templates, functions), your changes will be wiped out on the next update.
A child theme prevents this by giving you a protected space to add and override code without touching the original theme files.
🔧 What a Child Theme Really Is
A child theme is a small theme that inherits everything from your parent theme and then stacks your changes on top.
It can:
- Add new functions
- Override existing functions
- Replace template files
- Add CSS/JS
- Modify hooks
- Customize layout, output, HTML structure
The key is WordPress’s loading order:
👉 Child theme’s functions.php loads FIRST
👉 Parent theme’s functions.php loads AFTER
👉 Template files: child overrides parent by filename
This is what makes safe overriding possible.
📁 Basic Child Theme Structure (Parent theme = “mytheme”)
style.css
/*
Theme Name: MyTheme Child
Template: mytheme
Version: 1.0.0
*/
functions.php (correct way to enqueue parent styles)
<?php
function mytheme_child_enqueue_assets() {
wp_enqueue_style(
'mytheme-parent-style',
get_template_directory_uri() . '/style.css'
);
wp_enqueue_style(
'mytheme-child-style',
get_stylesheet_uri(),
['mytheme-parent-style']
);
}
add_action('wp_enqueue_scripts', 'mytheme_child_enqueue_assets');
🧩 1) Pluggable Functions (Function Overrides)
Pluggable functions are parent theme functions wrapped in:
if ( ! function_exists('function_name') ) {
function function_name() {
// parent logic
}
}
This means:
The parent only defines the function if it doesn’t already exist.
Because the child theme loads first, defining your own function takes priority.
The parent sees your function and skips its own version.
✔️ Example – overriding a parent function
Parent theme:
if ( ! function_exists('mytheme_render_header') ) {
function mytheme_render_header() {
echo "<h1>Default header</h1>";
}
}
Child theme:
function mytheme_render_header() {
echo "<h1>Custom header from child theme</h1>";
}
WordPress loads the child file, the function already exists → the parent will not define its version.
This is the safest and cleanest way to replace functionality.
🔄 2) Hook-Based Overrides (Actions & Filters)
Hooks give you fine-grained control without replacing full functions or templates.
They let you:
- remove parent theme behavior
- add your own behavior
- modify output
- reorder elements
- inject custom markup
Hooks are two types:
Actions
Insert behavior (e.g. print HTML, enqueue scripts).
Filters
Modify values (e.g. change a title, adjust a class, rewrite text).
✔️ Example – remove parent action & add your own
Parent theme:
add_action('wp_footer', 'mytheme_footer_info');
function mytheme_footer_info() {
echo "<p>Powered by MyTheme</p>";
}
Child theme:
function mytheme_child_customize_footer() {
// remove parent footer action
remove_action('wp_footer', 'mytheme_footer_info');
// add your custom version
add_action('wp_footer', 'mytheme_child_footer_info');
}
add_action('init', 'mytheme_child_customize_footer');
function mytheme_child_footer_info() {
echo "<p>Custom footer text from the child theme.</p>";
}
This is extremely powerful and requires no template overrides at all.
📄 3) Template File Overrides (Full Layout Replacement)
This method replaces entire template files from the parent theme.
If the parent theme has:
mytheme/
header.php
footer.php
single.php
page.php
template-parts/
content.php
You can copy any file into the same relative location inside your child theme:
mytheme-child/
single.php
WordPress will automatically use the version from the child theme.
✔️ Example – override a parent template
Step 1:
Copy single.php from parent:
mytheme/single.php → mytheme-child/single.php
Step 2:
Edit to your needs:
<?php
get_header();
?>
<h1 style="color: red;">Custom SINGLE template from child theme</h1>
<?php
// The rest of the template…
get_footer();
That’s it.
Your version completely replaces the parent template.
🎯 Summary — When to Use Which Method
✔️ Use pluggable functions
When you want to fully replace a function that the parent made override-safe.
✔️ Use hooks
When you want to modify or replace part of the behavior without touching templates.
✔️ Use template overrides
When you want to change HTML structure, markup, layout, template logic.
✔️ Use a child theme ALWAYS
If you’re adding code, logic, templates, or any file-level modifications.

