wp scaffold child-theme
Overview
Generate a child theme with all required files in seconds — style.css with correct Template header, functions.php with the parent stylesheet enqueue, and optionally a screenshot. Never manually create child theme files again.
What It Does
wp scaffold child-theme creates a new directory in wp-content/themes/ with a correctly structured style.css (child theme header) and a functions.php that enqueues the parent theme stylesheet. This is the safest, fastest way to start a child theme.
Syntax
wp scaffold child-theme <slug> [OPTIONS]
Options
| Flag | Description |
|---|---|
SLUG | Child theme directory name |
--parent_theme=SLUG | Parent theme slug (required) |
--theme_name=NAME | Human-readable theme name |
--author=NAME | Theme author name |
--author_uri=URL | Author URL |
--theme_uri=URL | Theme URL |
--activate | Activate the child theme after creation |
--force | Overwrite existing files |
Basic Usage
wp scaffold child-theme my-theme \
--parent_theme=twentytwentyfour \
--theme_name="My Custom Theme" \
--author="Jane Doe" \
--activate
Output:
Success: Created '/var/www/html/wp-content/themes/my-theme'.
Activating 'my-theme'...
Success: Switched to 'my-theme' theme.
Generated Files
style.css
/*
Theme Name: My Custom Theme
Author: Jane Doe
Template: twentytwentyfour
Version: 1.0.0
*/
functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
wp_enqueue_style(
'parent-style',
get_template_directory_uri() . '/style.css'
);
}
Real-World Scenarios
Scenario 1: Scaffold and activate immediately
wp scaffold child-theme my-client-theme \
--parent_theme=astra \
--theme_name="Client Theme" \
--author="Agency Name" \
--activate
Scenario 2: Create child theme for staging review
wp scaffold child-theme staging-child \
--parent_theme=generatepress \
--theme_name="Staging Child" \
--author="Dev Team"
Best Practices
- Always scaffold from a child theme — never modify parent theme files directly.
- Use
--activateto immediately switch to the child theme after creation. - Commit to version control right after creation so changes are tracked from the start.
Quick Reference
wp scaffold child-theme <slug> --parent_theme=<slug> # Basic
wp scaffold child-theme <slug> --parent_theme=<slug> --activate # Activate immediately
Next Steps
wp theme activate— activate manually if not using--activate.wp scaffold block— add Gutenberg blocks to the child theme.