A child theme lets you change templates and add PHP without your work being deleted by the next theme update.
You probably do not need one. For styling, use Additional CSS; for options, use the Customizer. Reach for a child theme when you need to change a template or hook into PHP.
The two files
Create wp-content/themes/stoat-child/:
style.css
/*
Theme Name: Stoat Child
Template: stoat
Version: 1.0.0
Text Domain: stoat-child
*/
/* Your CSS goes below. */
Template: stoat is what makes it a child. It must match the parent’s folder name exactly.
functions.php
<?php
/*
* Stoat enqueues get_stylesheet_uri() under the handle 'stoat_style'. In a
* child theme that resolves to THIS theme's style.css, so the parent sheet is
* never requested unless we ask for it. Load it first, at priority 5, and
* leave 'stoat_style' pointing at the child sheet — the Customizer's inline
* overrides attach to that handle and so still land last, after both files.
*/
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style(
'stoat_parent_style',
get_template_directory_uri() . '/style.css',
array(),
wp_get_theme( 'stoat' )->get( 'Version' )
);
}, 5 );
This step is not optional and not the usual boilerplate. Most child-theme tutorials tell you to enqueue the parent with get_parent_theme_file_uri() and leave it there. With Stoat, if you skip it your site loads the child’s empty stylesheet and nothing else, and the site appears completely unstyled.
Cache-busting your own sheet
After the snippet above, stoat_style points at the child’s style.css but still carries the parent’s version number, so your edits will not bust a browser cache. Re-stamp it:
add_action( 'wp_enqueue_scripts', function () {
$style = wp_styles()->query( 'stoat_style' );
if ( $style ) {
$style->ver = wp_get_theme()->get( 'Version' );
}
}, 11 );
Then bump Version: in the child’s header each time you change the CSS.
Activating it
Appearance → Themes → Activate, or:
wp theme activate stoat-child
What carries over
Menus and widgets are per-theme in WordPress and do not follow you to a child theme — you will need to reassign them once. Customizer settings do not carry over either.
Do this on a staging copy first if the site is live, or accept five minutes of a site with no menu.
Adding a screenshot
Drop a screenshot.png at 1200 × 900 in the child folder so it does not show as a blank tile in Appearance → Themes. Cosmetic, but you will look at that screen a lot.
