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 field | Required | Meaning |
|---|---|---|
Theme Name | Yes | Display name in wp-admin |
Template | Yes | Parent theme folder name (generatepress) |
Version | Recommended | Helps deployments and rollbacks |
Text Domain | Recommended | i18n domain for translations |
Common optional header fields:
| Header field | When to use | Notes |
|---|---|---|
Description | Human summary in wp-admin | Keep it short |
Author / Author URI | Attribution | Helpful in internal templates |
Requires at least | Compatibility note | Useful for teams |
Requires PHP | Compatibility note | Prevents older PHP installs |
License / License URI | OSS licensing | Required 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
| Practice | Why |
|---|---|
Keep Template: generatepress exact | Folder-name mismatch breaks inheritance |
| Use semantic versioning | Easier rollbacks |
Keep style.css small | Put most CSS in dedicated files |
Add a README.md | Document deploy and debug steps |
| Keep header fields consistent across environments | Prevents confusion during migration |
| Record compatibility fields | Helps teams avoid invalid deploy targets |
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| "Broken theme" in admin | Parent missing | Install/activate GeneratePress parent theme |
| Child theme not listed | Missing Theme Name | Add required header fields |
| Version not visible | No Version: field | Add a version line and redeploy |
| Admin shows wrong theme name | Cached metadata | Re-check header and clear any object cache |
Hands-On
- Print the first 40 lines of
style.css. - Verify
Template: generatepressand parent folder exists. - Add
Version:andText Domain:if missing. - Add one optional field (like
Description:) and confirm it appears inwp 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
- Next: Loading Styles & Scripts
- Related: Child Theme Structure