Every WordPress developer hits this moment. The theme is almost perfect, but one template needs to change. The product page layout is wrong. The footer markup is messy. A plugin outputs HTML you can’t style.
So you open the theme folder, find the file, and edit it directly.
Three weeks later the theme updates, your changes vanish, and the client is emailing you at 11 PM. I’ve watched this happen on more sites than I can count, and it’s completely avoidable.
Overriding templates the right way isn’t hard. You need to know where WordPress looks for files and which method fits the job. That answer has changed a bit since block themes and WooCommerce blocks became the default, so this guide covers both the classic and the modern setups.
In this guide:
- The one rule that saves you every time
- How WordPress finds templates
- Method 1: Child themes (classic themes)
- Method 2: Block themes (Full Site Editing)
- Method 3: Overriding plugin templates (WooCommerce)
- Making your own plugins override-friendly
- Should you override at all?
- Common mistakes and a checklist
- FAQ
The One Rule That Saves You Every Time
Never edit a parent theme or a plugin’s files directly.
That’s the rule. Anything you change inside wp-content/themes/storefront/ or wp-content/plugins/woocommerce/ is gone the moment that theme or plugin updates. You get no warning and no recovery.
Everything below is a structured way of following that rule.
First, Understand How WordPress Finds Templates
Before you override anything, you need to know how WordPress picks the template to load. This is the template hierarchy, and it decides everything else.
When someone visits a single blog post, WordPress doesn’t just grab index.php. It looks for the most specific file first and falls back to more general ones:
single-post-{slug}.php → single-post.php → single.php → singular.php → index.php

The first file it finds wins. That’s why overriding works at all. If you provide a more specific or higher-priority version of a template, WordPress uses yours.
Two locations matter for priority:
- The child theme is checked before the parent theme.
- For plugin templates, a set folder inside your theme is checked before the plugin’s own folder.
In short, a correct override puts your file where WordPress looks first.
Method 1: Child Themes (Classic Themes)
If you’re working with a classic (PHP-based) theme, a child theme is the standard answer. It’s a separate theme that inherits everything from its parent and lets you override individual files.
Set It Up
Create a new folder in wp-content/themes/, for example storefront-child/, with two files.
style.css — the header is what makes it a child theme. The Template: line must match the parent theme’s folder name exactly:
/*
Theme Name: Storefront Child
Template: storefront
Version: 1.0.0
*/
functions.php — this is the part most tutorials copy blindly. Before you write any enqueue code, open the parent theme’s functions.php and search for wp_enqueue_style. You’re checking two things:
- What handle the parent uses for its own stylesheet. Storefront uses
storefront-style, for example. - Whether the parent already loads the child stylesheet for you. Some do, Storefront included. In that case you don’t need any enqueue code at all.
If the parent loads only its own CSS, enqueue just the child stylesheet and set the parent’s handle as a dependency:
<?php
add_action( 'wp_enqueue_scripts', 'storefront_child_styles' );
function storefront_child_styles() {
wp_enqueue_style(
'storefront-child-style',
get_stylesheet_uri(),
array( 'storefront-style' ), // the parent's handle
wp_get_theme()->get( 'Version' )
);
}
The old habit of enqueuing the parent’s style.css again under a new handle like parent-style can load the same file twice. It’s not a disaster, but it’s an extra request and a source of confusing specificity bugs.
Activate the child theme. Your site looks identical, because it is identical until you override something.
Override a Template
Say you want to change page.php. Copy it from the parent theme into the child theme, keeping the same path:
wp-content/themes/storefront/page.php
↓ copy
wp-content/themes/storefront-child/page.php
Now edit the child’s copy. WordPress finds it first and ignores the parent’s version. The parent can update freely, and your override stays put.
The same logic applies to template parts in subfolders. Mirror the structure exactly:
storefront/template-parts/content.php
↓ copy
storefront-child/template-parts/content.php
Tip: Only copy the files you actually intend to change. Every file you copy is a file you now have to maintain. An override is a commitment, so keep the list short.
If you’re using one of our WordPress themes, the documentation lists which templates are safe to override and which hooks are available first.
Method 2: Block Themes (Full Site Editing)
Modern themes (Twenty Twenty-Four, Twenty Twenty-Five, and most new releases) are block themes, and the rules are different. Templates here are .html files made of block markup, not PHP.
your-block-theme/
├── templates/ ← full templates: index.html, single.html, page.html
├── parts/ ← reusable parts: header.html, footer.html
├── patterns/
└── theme.json ← global styles & settings
You have three ways to override, from least to most code:
1. The Site Editor (no code). Go to Appearance → Editor, open a template or part, and edit it visually. WordPress saves your changes to the database as a custom wp_template or wp_template_part entry. This matters: database customizations override the theme’s files. That’s great for clients, but those changes don’t live in version control. Keep that in mind on team projects.
2. File-based overrides in a child block theme. Same principle as classic child themes. A child block theme needs only a style.css with the same Template: line, plus an optional theme.json. The free Create Block Theme plugin from the WordPress.org team can generate one for you from the Site Editor. Then drop a same-named file into your child theme’s templates/ or parts/ folder and it wins over the parent’s:
parent-theme/templates/single.html
↓ copy into child
child-theme/templates/single.html
3. theme.json for styling. Don’t override a whole template just to change colors, spacing, or typography. A child theme’s theme.json lets you adjust global styles and settings cleanly, without touching markup at all.
The order to remember: Site Editor (database) → child theme files → parent theme files.
When Your File Changes “Don’t Work”
This is the most common block-theme headache. You edit templates/single.html, refresh, and nothing changes. Almost always, someone customized that template in the Site Editor at some point, and the database copy is winning.
The fix: open Appearance → Editor → Templates, find the template, open its actions menu, and choose Reset. That deletes the database copy, and WordPress goes back to reading your file. Export any Site Editor changes you want to keep before you reset, because the reset removes them.
Method 3: Overriding Plugin Templates (the WooCommerce Pattern)
This is where most developers go wrong. Plugins like WooCommerce ship their own templates, and you override those from your theme, not by editing the plugin.
WooCommerce checks your active theme for a woocommerce/ folder before falling back to its own templates. To override the product title template:
wp-content/plugins/woocommerce/templates/single-product/title.php
↓ copy to
wp-content/themes/your-theme/woocommerce/single-product/title.php
The subfolder path after templates/ must match exactly. Edit your copy, and WooCommerce loads it instead. Use your child theme here too, not the parent.
Experienced developers always do two things here:
- Check WooCommerce → Status. Scroll to the Templates section. It lists every override and flags any that are outdated. That means the plugin updated its version of the file, and yours may now be missing markup or breaking things. Outdated overrides are the number one cause of mysterious WooCommerce bugs.
- Re-audit overrides after major plugin updates. An override you copied two years ago is frozen in time while the plugin moves on. Keep them in sync.

Not every plugin supports this. The pattern only works if the plugin author built a template loader for it. More on that below.
The Catch: WooCommerce on Block Themes
This is the part many older tutorials miss. Everything above applies to classic themes. On a block theme, WooCommerce works differently:
- Shop, product, and archive pages use block templates, such as “Single Product” and “Product Catalog”. You edit them in Appearance → Editor, or override them with
.htmlfiles in your theme’stemplates/folder (for examplesingle-product.html). A PHP file inyour-theme/woocommerce/single-product/won’t change those pages. - Cart and Checkout are blocks by default on new installs since WooCommerce 8.3 (late 2023). If the page uses the Cart or Checkout block, overriding
cart/cart.phporcheckout/form-checkout.phpdoes nothing. Those blocks are customized through block settings, styles, and WooCommerce’s extensibility APIs, not PHP templates. - Emails, My Account, and many smaller partials still use the PHP template system, so classic overrides still work for those.
So before you copy a WooCommerce template, ask a quick question first: is this page rendered by a PHP template or by a block? If you’re on a block theme and the Site Editor shows the page as a WooCommerce block template, edit it there or with an .html override, not with a PHP file.
If You Build Plugins: Make Them Override-Friendly
If you ship your own plugins, let other developers override your templates the same way WooCommerce does. It takes very little code, and it earns a lot of goodwill.
The trick is a loader that checks the active theme first, then falls back to your plugin, with a filter at the end so developers can redirect it in code:
<?php
/**
* Load a template, allowing theme overrides.
*
* @param string $template_name e.g. 'booking/form.php'
* @param array $args Variables passed to the template as $args.
*/
function myplugin_get_template( $template_name, $args = array() ) {
// 1. Look in the active theme (child first, then parent): /myplugin/{template_name}
$template = locate_template( array( 'myplugin/' . $template_name ) );
// 2. Fall back to the plugin's own templates folder.
if ( ! $template ) {
$template = MYPLUGIN_PATH . 'templates/' . $template_name;
}
// 3. Let developers change the path programmatically.
$template = apply_filters( 'myplugin_get_template', $template, $template_name, $args );
if ( $template && file_exists( $template ) ) {
load_template( $template, false, $args );
}
}
Now anyone can override your booking/form.php by dropping a file at themes/their-theme/myplugin/booking/form.php.
The filter covers the cases a folder can’t. For example, another plugin can serve its own version of your template:
add_filter( 'myplugin_get_template', function ( $template, $template_name ) {
if ( 'booking/form.php' === $template_name ) {
return MY_ADDON_PATH . 'templates/booking-form.php';
}
return $template;
}, 10, 2 );
Note that this version uses load_template() with $args (available since WordPress 5.5) instead of extract(). Inside the template you read values as $args['booking_id']. That’s clearer to debug, and extract() is something WordPress.org plugin reviewers often flag.
The Better Question: Should You Override at All?
This is the mindset that separates a senior developer from someone who just knows the mechanics: overriding an entire template is often the wrong approach.
Every override is a copy you must maintain forever. The original keeps getting updates: security patches, accessibility fixes, new features. Your frozen copy doesn’t. So before you copy a file, ask whether a hook can do the job instead.
WordPress and well-built plugins are full of actions and filters designed for exactly this:
// Add a notice above the WooCommerce add-to-cart button,
// no template override needed.
add_action( 'woocommerce_before_add_to_cart_form', 'myshop_ships_fast_notice' );
function myshop_ships_fast_notice() {
echo '<p class="ships-fast">' . esc_html__( 'Ships within 24 hours', 'myshop' ) . '</p>';
}
That snippet survives every plugin update untouched. Compare it to copying and maintaining single-product/add-to-cart/simple.php.
I used a named function on purpose. Anonymous functions work, but nobody can remove_action() them later, including you, six months from now, inside a child theme.
Rule of thumb: If a hook or filter can make the change, use it. Override the full template only when you genuinely need to restructure the markup.
Common Mistakes I See Constantly
- Editing the parent theme or plugin directly. The original sin. Updates erase it.
- Copying the entire plugin templates folder “just in case.” Now you have 40 frozen files, 38 of which you didn’t need, all quietly going stale.
- Wrong
Template:slug in a child theme’sstyle.css. It must match the parent folder name exactly, including case. - Loading the parent stylesheet twice because a tutorial said to enqueue
parent-style, while the parent already does it. - Forgetting block-theme database precedence. A Site Editor change overrides your version-controlled template file, and you spend an hour wondering why your edits aren’t working. Reset the template.
- Using PHP overrides for WooCommerce block pages. On a block theme, product pages, Cart, and Checkout usually aren’t PHP templates anymore.
- Never re-auditing overrides after updates. WooCommerce’s Status page exists for a reason. Check it.
- Overriding when a hook would do. More maintenance for no benefit.
The Checklist: How to Override Theme Templates Correctly in WordPress
Before you override anything, run through this:
- Am I working in a child theme or a theme-level plugin override folder, and never in the original files?
- Is this page rendered by a PHP template or a block template?
- Can a hook or filter do this instead of a full template copy?
- Am I copying only the files I need, with their paths mirrored exactly?
- On a block theme, is there a Site Editor customization that will override my file?
- Have I written these overrides down so I’ll re-check them after the next update?
Get these right and template overriding stops being scary. Your customizations survive updates, your sites stay maintainable, and you never get that 11 PM email again.
FAQ
Does a child theme slow down WordPress?
Not in any way you’d notice. WordPress checks one extra folder when it looks for templates, and the child stylesheet is usually tiny. The real slowdown comes from loading the parent stylesheet twice, which the setup above avoids.
Can I override plugin templates without a child theme?
Technically yes. You can put the woocommerce/ folder in any active theme. But if that theme is a commercial theme you didn’t build, its next update can wipe your folder. Use a child theme unless the theme is your own custom build.
Why isn’t my WooCommerce template override working?
Check these in order. The folder path after templates/ doesn’t match exactly. You put the file in the parent theme while a child theme is active. Or you’re on a block theme, and the page is rendered by a block template, or by the Cart or Checkout block, not the PHP file you copied.
How do I know which template file a page uses?
Install the free Query Monitor plugin and open its Template panel on the front end. It shows the exact file loaded, plus every template part. On a block theme, the Site Editor shows which template is assigned.
Should I use Code Snippets or a child theme for small changes?
For a hook or two, a snippets plugin or a small site-specific plugin is fine, and it survives a theme switch. Use a child theme when you need to override actual template files or ship styles with the theme.
Wrapping Up
Override with intent, not with a text editor and a prayer.
If you’d rather have someone handle a tricky WooCommerce or theme customization for you, our team can help. We build and maintain WordPress themes every day, so we’ve run into most of these problems already.



