Skip to main content

style.css Header & Metadata

warning

If Template: is wrong, WordPress cannot connect your child theme to GeneratePress. Always verify the parent folder name is exactly generatepress.

style.css Header & Metadata Explained

Header fieldRequiredMeaning
Theme NameYesDisplay name in wp-admin
TemplateYesParent theme folder name (generatepress)
VersionRecommendedHelps deployments and rollbacks
Text DomainRecommendedi18n domain for translations

Common optional header fields:

Header fieldWhen to useNotes
DescriptionHuman summary in wp-adminKeep it short
Author / Author URIAttributionHelpful in internal templates
Requires at leastCompatibility noteUseful for teams
Requires PHPCompatibility notePrevents older PHP installs
License / License URIOSS licensingRequired if you distribute

Why It Matters

  • WP uses these headers to register and activate themes.
  • Versioning makes change control and rollback possible.
  • Text domain alignment avoids translation bugs.

How It Works

WordPress reads the style.css comment header in each theme directory. A child theme is recognized when it declares a valid Template: pointing to an installed parent theme.

Practical Walkthrough

Step 1: View the Current Header

view-style-css-header.sh
cd /var/www/html
sed -n '1,40p' wp-content/themes/generatepress-child/style.css

Step 2: Verify the Parent Folder Exists

verify-parent-folder.sh
cd /var/www/html
test -d wp-content/themes/generatepress && echo "parent generatepress folder exists"

Step 3: Validate Required Fields

validate-style-css-fields.sh
cd /var/www/html
grep -n "^Theme Name:" wp-content/themes/generatepress-child/style.css
grep -n "^Template:" wp-content/themes/generatepress-child/style.css
grep -n "^Version:" wp-content/themes/generatepress-child/style.css || true
grep -n "^Text Domain:" wp-content/themes/generatepress-child/style.css || true

Step 4: Confirm WP-CLI Sees the Child Theme

wp-cli-theme-inspection.sh
cd /var/www/html
wp theme get generatepress-child --fields=name,version,status 2>/dev/null || true
wp theme list | grep generatepress || true

Practical Examples

Example 1: A Standard Header Template

wp-content/themes/generatepress-child/style.css
/*
Theme Name: GeneratePress Child
Template: generatepress
Version: 0.1.0
Text Domain: generatepress-child
*/

Example 1b: A More Complete Header (Optional)

wp-content/themes/generatepress-child/style.css
/*
Theme Name: GeneratePress Child
Template: generatepress
Description: Custom child theme for Example Co.
Author: Example Co.
Version: 0.1.1
Requires at least: 6.0
Requires PHP: 8.1
Text Domain: generatepress-child
*/

Example 2: Bump Version During Deploy

During a release, update Version: and tag the Git repo so you can correlate site output to code.

Example 3: Add a Screenshot

Place screenshot.png in the child theme root:

wp-content/themes/generatepress-child/screenshot.png

Keep it small (compress it) so it does not bloat deploy artifacts.

Best Practices

PracticeWhy
Keep Template: generatepress exactFolder-name mismatch breaks inheritance
Use semantic versioningEasier rollbacks
Keep style.css smallPut most CSS in dedicated files
Add a README.mdDocument deploy and debug steps
Keep header fields consistent across environmentsPrevents confusion during migration
Record compatibility fieldsHelps teams avoid invalid deploy targets

Troubleshooting

SymptomCauseFix
"Broken theme" in adminParent missingInstall/activate GeneratePress parent theme
Child theme not listedMissing Theme NameAdd required header fields
Version not visibleNo Version: fieldAdd a version line and redeploy
Admin shows wrong theme nameCached metadataRe-check header and clear any object cache

Hands-On

  1. Print the first 40 lines of style.css.
  2. Verify Template: generatepress and parent folder exists.
  3. Add Version: and Text Domain: if missing.
  4. Add one optional field (like Description:) and confirm it appears in wp theme get.

Quick Reference

style-css-cheatsheet.sh
cd /var/www/html
grep -n "^Theme Name:\|^Template:\|^Version:\|^Text Domain:" wp-content/themes/generatepress-child/style.css

What's Next