Skip to main content

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.

warning

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)

ItemIt isIt is not
Child themeYour update-safe customization layerA replacement for plugins
Parent themeVendor code you update (GeneratePress)Where you should put custom changes
Template overrideA copied template in the child themeThe default way to customize everything

How Inheritance Works

There are two main inheritance paths:

  1. Templates: WordPress checks the child theme first, then falls back to the parent.
  2. 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:

PathPurpose
/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.phpHook/filter customizations
/var/www/html/wp-content/themes/generatepress-child/style.cssMetadata + child styles
List parent/child theme folders
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)
note

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.

wp-content/themes/generatepress-child/style.css (minimal header)
/*
Theme Name: GeneratePress Child
Template: generatepress
Version: 1.0.0
*/

And a functions.php that can enqueue styles or register hooks.

wp-content/themes/generatepress-child/functions.php (minimal scaffold)
<?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

SymptomLikely causeFast check
Child theme won't activateMissing/incorrect Template headerrg -n "^Template:" style.css
Styles not applyingCache or enqueue issuePurge cache, check page source for CSS
Site white screensPHP errorCheck /usr/local/lsws/logs/error.log

Quick Reference

Confirm active parent/child relationship
cd /var/www/html
wp option get stylesheet
wp option get template

What's Next