WordPress templates control how pages, posts, archives, products, categories, search results, and other sections of a website appear. Although a theme provides default templates, those files may not always support the design or functionality your website requires.

A WordPress template override lets you replace or extend a theme’s default template without editing WordPress core files. Depending on your theme and project, you can override templates through a child theme, create a custom page template, use the WordPress template hierarchy, edit a block template through the Site Editor, or load a template programmatically.

However, each method works differently. Using the wrong filename, folder, directory function, or template type can prevent WordPress from loading your customization.

This guide explains how to override WordPress templates safely in classic themes, child themes, block themes, custom post types, and WooCommerce websites.

What Is a WordPress Template Override?

A WordPress template override is the process of replacing a default template with a customized version.

For example, a parent theme may use single.php to display every blog post. You could add a customized single.php file to a child theme to change the layout without editing the parent theme.

You can also create more specific templates, such as:

single-book.php
archive-book.php
page-about.php
category-news.php
taxonomy-genre.php

WordPress uses its template hierarchy to determine which file should render each request. It starts with the most specific applicable template and falls back to a more general template when the specific file does not exist.

Template overriding is useful when you need to:

  • Create a unique layout for a page or post type
  • Change the design of category or archive pages
  • Customize WooCommerce product templates
  • Remove unnecessary theme elements
  • Add custom fields or dynamic content
  • Create landing pages with different structures
  • Modify reusable template parts
  • Preserve changes when the parent theme is updated

WordPress Template Override vs. Custom Page Template

A template hierarchy file, custom page template, and programmatic override are not the same thing.

Understanding this difference can prevent many common WordPress template problems.

MethodHow it worksExample
Template hierarchy fileWordPress selects it automatically for a matching requestpage-about.php
Assignable custom templateA user selects it from the page or post editortemplate-full-width.php
Child theme overrideReplaces a matching parent theme templatesingle.php
Programmatic overridePHP conditionally changes the template WordPress selectedtemplate_include
Block templateUses block markup in an HTML file or the Site Editor/templates/page.html

A file named page-about.php is automatically associated with a page whose slug is about. It does not need to be selected manually.

An editor-selectable custom page template normally uses a descriptive filename, such as template-full-width.php, and contains a Template Name header.

For pages, WordPress checks an assigned custom template before checking page-{slug}.php, page-{id}.php, page.php, singular.php, and finally index.php.

How the WordPress Template Hierarchy Works

When someone visits a URL, WordPress identifies the type of content being requested. It then checks the active theme for matching templates in a defined order.

If the most specific template is unavailable, WordPress moves to the next template in the hierarchy. In classic themes, these files normally use the .php extension. Block themes use .html templates, but the general hierarchy remains similar.

Page template hierarchy

For a standard WordPress page, the simplified hierarchy is:

Assigned custom template
page-{slug}.php
page-{id}.php
page.php
singular.php
index.php

For a page with the slug about, WordPress may look for:

page-about.php
page-42.php
page.php
singular.php
index.php

Single post hierarchy

For an individual post or custom post type entry, WordPress may use:

single-{post-type}-{slug}.php
single-{post-type}.php
single.php
singular.php
index.php

For a custom post type named book, you could create:

single-book.php

Archive hierarchy

For an archive, WordPress may check:

archive-{post-type}.php
archive.php
index.php

For a book custom post type archive, the file would be:

archive-book.php

Category hierarchy

category-{slug}.php
category-{id}.php
category.php
archive.php
index.php

For a category with the slug news, use:

category-news.php

Tag hierarchy

tag-{slug}.php
tag-{id}.php
tag.php
archive.php
index.php

Taxonomy hierarchy

taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
taxonomy.php
archive.php
index.php

For a custom taxonomy named genre, use:

taxonomy-genre.php

For the fiction term inside that taxonomy, use:

taxonomy-genre-fiction.php

Author hierarchy

author-{nicename}.php
author-{id}.php
author.php
archive.php
index.php

Other useful templates

front-page.php
home.php
search.php
404.php
date.php
attachment.php
comments.php

You do not need to create every possible template. Create only the files required for your design, and WordPress will continue using fallback templates for everything else.

Identify Whether You Use a Classic or Block Theme

Before modifying a template, determine which type of WordPress theme is active.

Signs of a classic theme

A classic theme usually:

  • Uses .php template files
  • Contains files such as index.php, page.php, and single.php
  • Uses functions such as get_header() and get_footer()
  • Uses the Customizer or theme options for many design settings
  • Does not provide full template editing under Appearance

Signs of a block theme

A block theme usually:

  • Contains /templates/index.html
  • Uses HTML files with WordPress block markup
  • Provides Appearance → Editor
  • Allows headers, footers, templates, and global styles to be edited with blocks
  • Commonly uses theme.json

The presence of /templates/index.html is a key distinction that makes a theme a block theme.

Some themes combine classic PHP templates with selected block-theme features. These are often described as hybrid themes. Inspect the active theme’s files before choosing an override method.

Why You Should Use a Child Theme

Directly editing a third-party parent theme is risky. When the theme is updated, its files may be replaced and your modifications can be lost.

A child theme inherits the parent theme’s functionality while allowing you to add or override templates separately.

WordPress allows a child theme to override a parent theme’s template, template part, or pattern by supplying a matching file. However, a child theme’s functions.php does not replace the parent theme’s functions.php; both files are loaded.

Basic classic child theme structure

wp-content/
└── themes/
    ├── parent-theme/
    └── parent-theme-child/
        ├── style.css
        └── functions.php

Add the following header to the child theme’s style.css file:

/*
Theme Name: Parent Theme Child
Description: Custom child theme for safe template overrides
Template: parent-theme
Version: 1.0.0
*/

The value of Template must exactly match the parent theme’s folder name.

Activate the child theme from Appearance → Themes before adding your overrides.

Depending on how the parent theme loads its stylesheets, you may also need to enqueue the parent stylesheet in the child theme’s functions.php. Check the parent theme’s documentation because not every theme handles styles in the same way.

How to Override a Template in a Classic Child Theme

The most common way to override a classic WordPress template is to copy it into the child theme.

Suppose the parent theme contains:

wp-content/themes/parent-theme/single.php

Copy that file to:

wp-content/themes/parent-theme-child/single.php

Edit only the child theme copy.

When WordPress needs single.php, it will use the child theme version instead of the matching parent theme version.

Preserve the relative folder structure

If the parent theme uses:

parent-theme/template-parts/content/content-page.php

Place the override at:

parent-theme-child/template-parts/content/content-page.php

The filename and relative directory structure should match.

WordPress functions such as get_template_part() are designed to allow reusable template sections to be overloaded by child themes.

Important template hierarchy detail

A general child theme template does not always override a more specific parent theme template.

For example:

Child theme:
category.php

Parent theme:
category-news.php

When WordPress displays the news category, the more specific category-news.php in the parent theme may be selected before the general category.php in the child theme.

To override that category, create this file in the child theme:

category-news.php

WordPress considers template specificity as well as whether the file belongs to the parent or child theme.

How to Create a Template for One Specific Page

To automatically apply a template to one page, name the template using the page slug or ID.

For a page located at:

example.com/about/

Create:

page-about.php

A simple example could look like this:

<?php
/**
 * Template for the About page.
 */

get_header();
?>

<main id="primary" class="site-main site-main--about">
	<?php
	while ( have_posts() ) :
		the_post();
		?>
		<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<header class="entry-header">
				<h1 class="entry-title"><?php the_title(); ?></h1>
			</header>

			<div class="entry-content">
				<?php the_content(); ?>
			</div>
		</article>
		<?php
	endwhile;
	?>
</main>

<?php
get_footer();

Upload the file to the root of the active child theme:

parent-theme-child/page-about.php

WordPress will automatically load it for the page with the about slug.

You do not need to add a Template Name header or select the template from the editor for this method.

How to Create an Assignable Custom Page Template

An assignable custom page template is useful when the same layout should be available for multiple pages.

Create a file such as:

template-full-width.php

Add a template header:

<?php
/**
 * Template Name: Full Width Page
 * Template Post Type: page
 */

get_header();
?>

<main id="primary" class="site-main site-main--full-width">
	<?php
	while ( have_posts() ) :
		the_post();
		?>
		<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
			<header class="entry-header">
				<h1 class="entry-title"><?php the_title(); ?></h1>
			</header>

			<div class="entry-content">
				<?php the_content(); ?>
			</div>
		</article>
		<?php
	endwhile;
	?>
</main>

<?php
get_footer();

Upload it to the child theme. You can then edit a page and select Full Width Page from the Template setting.

WordPress page templates can also support posts and custom post types when those types are included in the Template Post Type header.

For example:

<?php
/**
 * Template Name: Content Without Sidebar
 * Template Post Type: page, post, book
 */

Only include post types for which the template has been properly designed and tested.

How to Override Single Posts and Custom Post Types

The standard single.php file controls individual posts when no more specific template is available.

To customize all standard blog posts, add:

single.php

To customize a custom post type called book, add:

single-book.php

Example:

<?php
/**
 * Single Book template.
 */

get_header();
?>

<main id="primary" class="site-main">
	<?php
	while ( have_posts() ) :
		the_post();
		?>
		<article id="post-<?php the_ID(); ?>" <?php post_class( 'single-book' ); ?>>
			<header class="book-header">
				<h1><?php the_title(); ?></h1>
			</header>

			<div class="book-content">
				<?php the_content(); ?>
			</div>
		</article>
		<?php
	endwhile;
	?>
</main>

<?php
get_footer();

Make sure the filename uses the registered post type slug, not its singular label.

For example, if a post type is registered as:

register_post_type( 'book', $args );

The correct filename is:

single-book.php

It is not:

single-books.php

How to Create a Custom Post Type Archive Template

When the custom post type has archives enabled, you can create:

archive-book.php

Example:

<?php
/**
 * Book archive template.
 */

get_header();
?>

<main id="primary" class="site-main book-archive">
	<header class="page-header">
		<h1><?php post_type_archive_title(); ?></h1>
	</header>

	<?php if ( have_posts() ) : ?>
		<div class="book-grid">
			<?php
			while ( have_posts() ) :
				the_post();
				?>
				<article id="post-<?php the_ID(); ?>" <?php post_class( 'book-card' ); ?>>
					<h2>
						<a href="<?php the_permalink(); ?>">
							<?php the_title(); ?>
						</a>
					</h2>

					<?php the_excerpt(); ?>
				</article>
				<?php
			endwhile;
			?>
		</div>

		<?php the_posts_pagination(); ?>

	<?php else : ?>

		<p><?php esc_html_e( 'No books were found.', 'your-text-domain' ); ?></p>

	<?php endif; ?>
</main>

<?php
get_footer();

After changing a custom post type’s rewrite or archive settings, you may need to visit Settings → Permalinks and save the settings once to refresh rewrite rules.

Do not repeatedly flush rewrite rules on every page load because that adds unnecessary work to normal requests.

How to Override Category, Tag, and Taxonomy Templates

WordPress lets you create unique archive layouts for categories, tags, and custom taxonomy terms.

Category template examples

category.php
category-news.php
category-12.php

Tag template examples

tag.php
tag-tutorials.php
tag-18.php

Custom taxonomy examples

For a taxonomy registered as genre:

taxonomy-genre.php

For only its fiction term:

taxonomy-genre-fiction.php

A dedicated taxonomy template can be useful when the archive needs custom introductory content, filters, field values, cards, or a layout that differs from standard blog archives.

How to Override Template Parts

Large templates are often divided into reusable sections called template parts.

A classic theme may load a part using:

get_template_part( 'template-parts/content', 'single' );

WordPress will look for:

template-parts/content-single.php

To override the part, copy the matching file into the child theme:

parent-theme-child/template-parts/content-single.php

You can also create a fallback:

template-parts/content.php

WordPress first attempts to load the more specific named part before falling back to the general part.

Use template-part overrides when you need to change only one reusable section. Replacing a small part is often easier to maintain than copying an entire page template.

How to Load a Custom Template Programmatically

Sometimes a filename alone is not enough. You may need to load a custom template based on page data, a custom field, user capability, or another condition.

The template_include filter runs immediately before WordPress includes its selected template, making it suitable for changing the final template path.

Add this code to the child theme’s functions.php or a site-specific plugin:

<?php
/**
 * Load a custom template for the About page.
 *
 * @param string $template Current template path.
 * @return string
 */
function codecanel_load_about_template( $template ) {
	if ( ! is_page( 'about' ) ) {
		return $template;
	}

	$custom_template = locate_template(
		array( 'templates/about-page.php' )
	);

	if ( $custom_template ) {
		return $custom_template;
	}

	return $template;
}

add_filter( 'template_include', 'codecanel_load_about_template', 99 );

Create the corresponding file:

parent-theme-child/templates/about-page.php

The locate_template() function searches the active child theme before searching the parent theme, which makes the override compatible with child-theme workflows.

Do not create a template path directly from unvalidated user input. Template filenames should come from a controlled list of trusted values.

Why not always use get_template_directory()?

This code can cause problems in a child theme:

get_template_directory() . '/templates/about-page.php';

When a child theme is active, get_template_directory() returns the parent theme directory. It does not point to the child theme.

Depending on the task, use one of these instead:

locate_template()
get_stylesheet_directory()
get_theme_file_path()

locate_template() is usually the best choice when you want WordPress to search the child theme first and then fall back to the parent theme.

How to Override Templates in a WordPress Block Theme

Block themes use block markup inside .html template files.

Their top-level templates belong in:

your-theme/templates/

Common block template files include:

templates/index.html
templates/page.html
templates/single.html
templates/archive.html
templates/search.html
templates/404.html
templates/front-page.html

Block theme template parts commonly belong in:

your-theme/parts/

Examples include:

parts/header.html
parts/footer.html
parts/sidebar.html

WordPress officially defines /templates as the location for distributable block templates.

Method 1: Edit a block template through the Site Editor

Go to:

Appearance → Editor → Design → Templates

Select the template you want to modify, edit its blocks, and save the changes.

When a theme-provided template is edited through the Site Editor, WordPress keeps the original theme file and stores a customized version in the database. That customized version can take priority over the file in the active theme.

This explains a common problem: you may edit templates/page.html, but the front end continues showing an older design saved through the Site Editor.

To resolve it:

  1. Open Appearance → Editor → Templates.
  2. Find the customized template.
  3. Open its options.
  4. Choose Clear customizations or Reset.
  5. Confirm that the theme file is now being loaded.

Resetting removes the saved customization and restores the template supplied by the theme.

Method 2: Override a parent block theme template

Suppose the parent block theme contains:

parent-theme/templates/single.html

Create the matching file in the child block theme:

parent-theme-child/templates/single.html

A basic block template could contain:

<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main class="wp-block-group">
	<!-- wp:post-title {"level":1} /-->

	<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
</main>
<!-- /wp:group -->

<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->

You can edit block markup directly or build the layout visually in the Site Editor and export the completed theme files.

How to Register a Custom Block Template in theme.json

Block themes can register editor-selectable custom templates through the customTemplates property in theme.json.

Add:

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"customTemplates": [
		{
			"name": "landing-page",
			"title": "Landing Page",
			"postTypes": [
				"page"
			]
		}
	]
}

Create the matching template file:

templates/landing-page.html

Example:

<!-- wp:template-part {"slug":"header","tagName":"header"} /-->

<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
<main class="wp-block-group">
	<!-- wp:post-title {"level":1,"textAlign":"center"} /-->

	<!-- wp:post-content /-->
</main>
<!-- /wp:group -->

<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->

After registration, users can select Landing Page from the page’s Template setting.

The customTemplates setting is designed for selectable single post, page, and custom post type templates. It is not the method used to register category or archive hierarchy templates.

How to Override WooCommerce Templates

WooCommerce includes PHP templates for product pages, archives, cart components, emails, account areas, and other store content.

For classic WooCommerce templates, the original files are located under:

wp-content/plugins/woocommerce/templates/

Do not edit those plugin files directly. Plugin updates will replace them.

Instead, copy the required file into a woocommerce directory inside the active child theme.

Example: Single product template

Copy:

wp-content/plugins/woocommerce/templates/single-product.php

To:

wp-content/themes/your-child-theme/woocommerce/single-product.php

Example: Product image template

Copy:

wp-content/plugins/woocommerce/templates/single-product/product-image.php

To:

wp-content/themes/your-child-theme/woocommerce/single-product/product-image.php

Preserve the directory structure below WooCommerce’s /templates folder.

Use hooks for small WooCommerce changes

A full template override is not always necessary.

When you only need to move, remove, or insert one element, a WooCommerce action or filter may be easier to maintain than copying an entire template.

Use a full override when the HTML structure requires substantial changes. Use hooks when the existing structure is acceptable and only a targeted adjustment is needed.

Check for outdated WooCommerce templates

WooCommerce occasionally updates its template files. Your copied version does not update automatically, so an old override can become incompatible with the current plugin version.

Review the WooCommerce status report for outdated template notices. When an override is outdated:

  1. Back up your customized file.
  2. Copy the latest original template from WooCommerce.
  3. Compare the old and new versions.
  4. Reapply only the custom changes you still need.
  5. Test the updated file on a staging site.

WooCommerce recommends updating the copied template and reproducing your required changes when its template structure changes.

Be careful with woocommerce.php

A classic theme can declare WooCommerce support using a woocommerce.php file. However, that file can take priority over woocommerce/archive-product.php, preventing the archive override from being used as expected.

Check whether the active theme already contains:

woocommerce.php

before troubleshooting an ignored archive-product.php file.

WooCommerce block themes

WooCommerce also provides block-based templates and components. A block theme can supply templates such as:

templates/single-product.html

That theme template can take priority over the WooCommerce default Single Product template.

Block-based cart and checkout pages should continue rendering their assigned page content through the Post Content block. Removing the Cart or Checkout block from the page content can break the expected experience.

How to Find Which WordPress Template Is Loading

When an override does not work, first confirm which template WordPress is actually using.

During development, you can temporarily log the selected template:

<?php
/**
 * Log the selected template while WordPress debugging is enabled.
 *
 * @param string $template Selected template.
 * @return string
 */
function codecanel_log_selected_template( $template ) {
	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
		error_log(
			'WordPress template: ' . wp_basename( $template )
		);
	}

	return $template;
}

add_filter( 'template_include', 'codecanel_log_selected_template', 999 );

Remove the snippet after troubleshooting.

You should also check:

  • The active theme and child theme
  • The requested content type
  • The exact post type or taxonomy slug
  • The page slug and ID
  • Whether a custom page template is assigned
  • Whether a more specific parent template exists
  • Whether a Site Editor customization is stored in the database
  • Whether a caching system is serving an older version
  • Whether a plugin is filtering the template

Common WordPress Template Override Problems

1. The child theme template is not loading

Possible causes:

  • The child theme is not active
  • The filename is incorrect
  • The folder structure does not match
  • A more specific template exists
  • The parent theme uses a custom loading system
  • The requested content type is different from what you expected

Solution:

Confirm the active child theme, inspect the hierarchy, and copy the exact relative path from the parent theme.

2. The custom template does not appear in the editor

Possible causes:

  • The Template Name header is missing
  • The header contains a syntax error
  • The template is assigned to the wrong post type
  • The theme does not support the expected template workflow
  • The file is stored in an unsupported directory

Solution:

Use a valid template header:

<?php
/**
 * Template Name: Full Width Page
 * Template Post Type: page
 */

Then reload the editor.

3. page-about.php does not appear in the template dropdown

This is expected.

page-about.php is an automatic hierarchy template, not necessarily an editor-selectable template.

To create a selectable template, use a different filename and add a Template Name header.

4. WordPress keeps loading index.php

WordPress uses index.php as the final fallback when it cannot find a more specific matching template.

Check:

  • The requested query type
  • File spelling
  • Post type slug
  • Taxonomy slug
  • Active theme directory
  • Template hierarchy order

5. Custom post type template is not loading

Make sure the filename uses the registered post type key:

single-{post-type}.php

For:

register_post_type( 'portfolio', $args );

Use:

single-portfolio.php
archive-portfolio.php

Do not use the post type’s display label unless it is also the registered key.

6. Archive page returns a 404 error

The post type may not have archives enabled, or rewrite rules may need to be refreshed.

Verify that registration includes an appropriate archive setting, then visit Settings → Permalinks and save once.

7. Changes appear in the file but not on the website

Clear:

  • WordPress caching plugins
  • Server or hosting cache
  • CDN cache
  • Browser cache
  • Page-builder cache
  • Generated CSS cache

For block themes, also check whether a customized template saved in the Site Editor is overriding the file.

8. The wrong theme directory is used

get_template_directory() points to the parent theme when a child theme is active.

Use locate_template(), get_stylesheet_directory(), or get_theme_file_path() when the child theme should take priority.

9. WooCommerce override is ignored

Check:

  • The /woocommerce/ folder name
  • The copied file’s relative directory
  • The active child theme
  • Template version compatibility
  • Whether the store uses a block-based template
  • Whether woocommerce.php has priority
  • Whether a plugin or theme hook changes the output

10. A block template file is ignored

A Site Editor customization may be stored in the database.

Open Appearance → Editor → Templates and reset or clear the customization for the affected template.

WordPress Template Override Best Practices

Always work on a staging website

A broken PHP template can cause a fatal error or incomplete page output. Test changes on staging before deploying them to a live website.

Back up the website first

Back up the database and files before changing themes, templates, plugin overrides, or functions.php.

Avoid editing WordPress core files

Core modifications are overwritten during updates and can create security and maintenance problems.

Avoid editing third-party parent themes directly

Use a child theme or a site-specific plugin so updates do not remove your work.

Copy only the templates you need

Every copied template becomes code you may need to maintain. Do not duplicate an entire parent theme when you only need one file.

Prefer hooks for small changes

When an action, filter, template part, or block pattern can achieve the result, use that smaller customization instead of copying a full template.

Follow WordPress coding standards

Escape dynamic output, sanitize incoming values, use translation functions, and avoid placing sensitive business logic directly inside view templates.

Examples include:

esc_html()
esc_attr()
esc_url()
sanitize_text_field()
wp_kses_post()

Keep business logic outside templates

Templates should mainly control presentation.

Move reusable data processing and complex logic into:

  • functions.php
  • A theme include file
  • A custom plugin
  • A service or class

Then pass the prepared information into the template.

Document every override

Add a short comment explaining:

  • Which original file was copied
  • Why it was overridden
  • When it was last reviewed
  • Which plugin or parent theme version it was compared with

This is especially important for WooCommerce templates.

Review overrides after updates

After updating a parent theme, WordPress, or WooCommerce, compare major template changes with your child theme copies.

Test multiple content states

Test templates with:

  • Long and short titles
  • Missing featured images
  • Empty content
  • Multiple categories
  • Pagination
  • Comments enabled and disabled
  • Logged-in and logged-out users
  • Mobile and desktop screens
  • Different user roles
  • Empty archives
  • Search results with no matches

Maintain accessibility

Use semantic headings, visible focus states, keyboard-friendly controls, form labels, descriptive links, and appropriate landmark elements.

Check performance

Avoid expensive database queries inside loops. Reuse prepared data, optimize media, and load assets only where they are required.

WordPress Template Filename Cheat Sheet

Content typeTemplate example
All pagespage.php
Specific page by slugpage-about.php
Specific page by IDpage-42.php
Editor-selectable page templatetemplate-full-width.php
All postssingle.php
Custom post type entrysingle-book.php
General archivesarchive.php
Custom post type archivearchive-book.php
All categoriescategory.php
Specific categorycategory-news.php
All tagstag.php
Specific tagtag-tutorials.php
Custom taxonomytaxonomy-genre.php
Specific taxonomy termtaxonomy-genre-fiction.php
Author archiveauthor.php
Search resultssearch.php
Error page404.php
Blog posts indexhome.php
Site front pagefront-page.php
Block page template/templates/page.html
Block single template/templates/single.html
Block header part/parts/header.html
WooCommerce product/woocommerce/single-product.php

Conclusion

Learning how to override WordPress templates gives you much greater control over your website’s layout and functionality.

For classic themes, the safest approach is generally to create a child theme and add a matching or more specific PHP template. For reusable editor-selectable layouts, create a properly registered custom page template. For conditional behavior, use template_include with a child-theme-aware function such as locate_template().

Block themes use a different workflow. Their templates are built with block markup, stored in the /templates directory, and can also be customized through the Site Editor. Because Site Editor changes may be stored in the database, always check for saved customizations when a file-based block template appears to be ignored.

WooCommerce templates require additional maintenance because copied files can become outdated as the plugin evolves. Override only what you need, use hooks for smaller changes, and review customized templates after updates.

By following the template hierarchy, preserving child theme compatibility, and choosing the smallest effective customization method, you can build flexible WordPress layouts without making future updates unnecessarily difficult.

Frequently Asked Questions

Can I override a WordPress template without a child theme?

Technically, yes. You can edit a custom theme you fully control, use a site-specific plugin with template filters, or edit a block template through the Site Editor.
However, directly modifying a third-party parent theme is not recommended because theme updates can replace your changes.

How do I change a template in WordPress?

For a classic theme, create a child theme and override the appropriate PHP template. For an assignable layout, create a template with a Template Name header. For a block theme, use the Site Editor or add an HTML file to the theme’s /templates directory.

This page was last edited on 23 July 2026, at 6:30 pm