DEV3 Technologies home

Child theme starter

A minimal child theme with a correct stylesheet header and a functions file that loads parent and child styles with cache busting.

WordPressThemingchild-themeenqueuecustomisationstarter

Code

/*
Theme Name:   Acme Theme Child
Theme URI:    https://example.com/
Description:  Child theme for Acme Theme. Put overrides here, not in the parent.
Author:       Acme Studio
Template:     acme-theme
Version:      1.0.0
License:      GNU General Public License v2 or later
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  acme-theme-child
*/

/* Your overrides go below. */

How it works

What it solves

Editing a theme directly loses your changes at the next update. A child theme inherits everything from its parent, and only the files you override live in it, so you can customise safely and still receive upstream fixes.

How it works

The Template header names the parent theme's folder, which is what makes WordPress treat this as a child. The stylesheet itself can be almost empty because it is loaded through code. The functions file enqueues the parent stylesheet first using the parent's version number, then the child's with a dependency on the parent and a file modification time as the version, so edits show immediately without a stale cache.

The child's functions.php runs before the parent's.

Adapting it

Copy a template such as header.php from the parent into the child folder to override it. Use filters and actions for logic changes. Replace acme-theme in the header with the real parent folder name. If the parent already enqueues its own stylesheet, remove the parent enqueue here to prevent loading it twice.

Pitfalls

  • The Template value is the parent's directory name, not its display name.
  • Do not use @import in the stylesheet; it blocks rendering.
  • Parent functions wrapped in function_exists can be redefined, others cannot.
  • Block themes need parent theme.json overrides in the child's own theme.json instead.

How to use it

Create a folder next to the parent theme, for example wp-content/themes/acme-child.

Add the two files, then activate Acme Theme Child in Appearance, Themes.

Add CSS overrides to the child stylesheet.

Licence: GPL-2.0-or-later. This snippet comes from WordPress code and is GPL-2.0-or-later.

Related snippets