WordPress

Child theme

Child theme is a small WordPress theme that inherits everything from a parent theme and overrides only the files you copy or add. Updating the parent leaves your changes intact.

How it is measured

The minimum is a folder in wp-content/themes with a style.css whose header includes Template: followed by the parent's folder name, and usually a functions.php. WordPress loads the child's functions.php before the parent's, and for template files it prefers the child's copy if one exists.

Confirm the setup in Appearance > Themes, where the child shows as Active and names its parent. In code, get_stylesheet_directory() points to the child and get_template_directory() points to the parent.

Worked example

A law firm runs Astra Pro and wants a different footer. The developer creates astra-child with a style.css and a copy of footer.php, then edits three lines. Two months later Astra releases version 4.8 and the firm updates; the footer edit survives, while a colleague who edited footer.php in the parent loses the change.

A different pitfall: the child's style.css has Template: astra-theme but the parent folder is astra, so WordPress reports a broken theme and the site falls back to the default.

How it differs

A child theme depends on a theme and needs a parent theme present on disk. Delete the parent folder and the child fails. The child holds your overrides only, so it should not contain a full copy of the parent. A child theme does nothing a small plugin cannot do for behavior, so use it for template and style changes.

Common errors

Writing the wrong parent folder name in the Template header. Forgetting to enqueue the parent's stylesheet, which makes the site render unstyled. Copying every parent file into the child and losing parent bug fixes. Putting functionality that should survive a theme switch in functions.php. Customizer settings not carrying over when you activate the child, since options are stored per theme.

In practice

If you have edited files inside a purchased theme, diff them against the original and move the changes into a child theme before the next update. Start with only the files you changed. Keep behavior that is not about presentation in a plugin.

See also

Theme, Parent theme

Sources

Count this on a real site.

Watch my website