What Is a Child Theme
A child theme is a WordPress theme that depends on another theme (the parent). WordPress loads the parent theme, then overlays the child theme on top. You use the child theme to add versioned CSS/JS and small PHP changes without editing vendor code.
If you edit functions.php on production and introduce a PHP syntax error, you can take the site down. Use staging and keep a rollback command ready.
What a Child Theme Is (and What It Is Not)
| Item | It is | It is not |
|---|---|---|
| Child theme | Your update-safe customization layer | A replacement for plugins |
| Parent theme | Vendor code you update (GeneratePress) | Where you should put custom changes |
| Template override | A copied template in the child theme | The default way to customize everything |
How Inheritance Works
There are two main inheritance paths:
- Templates: WordPress checks the child theme first, then falls back to the parent.
- Behavior: your child theme registers hooks/filters, and WordPress executes them during the request.
flowchart TD
WP[WordPress] --> PARENT[GeneratePress parent theme]
PARENT --> CHILD[Child theme]
CHILD --> HOOKS[Hooks/filters in functions.php]
CHILD --> TPL["Template overrides (optional)"]
TPL -->|fallback| PTPL[Parent templates]
HOOKS --> OUT[Rendered output]
PTPL --> OUT
Where Child Themes Live on Disk
Typical paths on an Ubuntu server:
| Path | Purpose |
|---|---|
/var/www/html/wp-content/themes/generatepress/ | Parent theme (vendor) |
/var/www/html/wp-content/themes/generatepress-child/ | Child theme (yours) |
/var/www/html/wp-content/themes/generatepress-child/functions.php | Hook/filter customizations |
/var/www/html/wp-content/themes/generatepress-child/style.css | Metadata + child styles |
cd /var/www/html
ls -lah wp-content/themes | rg -n "generatepress$|generatepress-child$" || true
When You Should Use a Child Theme
Use a child theme when you need versioned, deployable changes:
- Custom PHP (hooks/filters, shortcodes, integrations)
- A small asset pipeline (CSS/JS) you want to ship through Git
- A repeatable deployment workflow across staging/production
Use Elements and the Customizer when you do not need code:
- Conditional headers/CTAs
- Layout changes by context
- Design system settings (typography/colors/spacing)
The best GeneratePress workflow is usually: Customizer + blocks first, Elements second, child theme only when code is required.
Minimal Child Theme: The Two Files That Matter
At minimum, a child theme needs a valid style.css header that points to the parent theme.
/*
Theme Name: GeneratePress Child
Template: generatepress
Version: 1.0.0
*/
And a functions.php that can enqueue styles or register hooks.
<?php
add_action( 'wp_enqueue_scripts', function () {
// Optional: enqueue a child stylesheet.
wp_enqueue_style(
'gp-child',
get_stylesheet_uri(),
[],
'1.0.0'
);
} );
Troubleshooting Quick Checks
| Symptom | Likely cause | Fast check |
|---|---|---|
| Child theme won't activate | Missing/incorrect Template header | rg -n "^Template:" style.css |
| Styles not applying | Cache or enqueue issue | Purge cache, check page source for CSS |
| Site white screens | PHP error | Check /usr/local/lsws/logs/error.log |
Quick Reference
cd /var/www/html
wp option get stylesheet
wp option get template
What's Next
- Next: Why Use a Child Theme
- Later: Create Child Theme via CLI