A template part in WordPress is a reusable block of content or layout that can be inserted into multiple page templates. Rather than building a header or footer from scratch on every template, a template part stores that component once and references it wherever it’s needed. Change the template part, and the update propagates to every template using it.

Template parts are a core concept in both classic theme development (using PHP) and the newer Full Site Editing (FSE) block theme approach. The underlying idea is the same in both cases — separate repeating UI components from the unique content of individual page layouts, making themes easier to build and maintain. For site owners, the result is a website where common elements like headers, footers, and sidebars stay consistent and are easy to update.

[Image: Diagram showing a page template with labeled template parts — header.html, footer.html, and content — assembled into a complete page layout]

How Template Parts Work

In a classic (PHP-based) WordPress theme, template parts are PHP files stored in the theme directory. The function get_template_part() loads them into other template files:

  • header.php — Typically loaded at the top of every template with get_header()
  • footer.php — Loaded at the bottom with get_footer()
  • sidebar.php — Loaded where needed with get_sidebar()
  • Custom parts like content-card.php — Loaded anywhere with get_template_part('content', 'card')

In a block (FSE) theme, template parts are HTML files stored in the /parts directory of the theme. They contain block markup rather than PHP. The Site Editor lets users visually edit these parts — meaning a non-developer can update the header or footer directly from the WordPress dashboard without touching code.

Block theme template parts are named descriptively: header.html, footer.html, sidebar.html, and custom parts like post-meta.html. They’re referenced in template files using the Template Part block in the Site Editor.

Starting with WordPress 6.1, even classic themes can include block-based template parts in a /parts folder, creating a hybrid approach that gives developers PHP control over templates while offering editors block-based customization of specific sections.

Purpose & Benefits

1. Consistency Across the Entire Site

Template parts enforce consistency by ensuring that the header, footer, and other shared elements are defined in one place. Every page that uses the header template part will always show the same header — no divergence, no outdated versions on forgotten pages. When you need to update the header, you do it once and it updates everywhere. Our WordPress development process uses template parts on every project we build.

2. Faster Development and Maintenance

Building themes with template parts means each component is written once and reused, rather than duplicated across every template file. This significantly speeds up development and reduces the surface area for bugs. When a client needs to add a promotional banner to the top of every page, the change happens in one template part rather than across dozens of template files.

3. Non-Developer Editing With Block Themes

In block-based themes, template parts are editable through the WordPress Site Editor — no code required. A business owner or content editor can update the footer with new contact information, revise the header navigation, or adjust the sidebar layout directly from the WordPress dashboard. This gives non-technical users meaningful control over structural elements without needing developer support for routine updates. Full Site Editing makes this possible.

Examples

1. Classic Theme: Reusable Product Card

A classic theme developer creates a template part for displaying a product preview card:

// In the template file, call the part:
get_template_part( 'template-parts/content', 'product-card' );

// WordPress loads: /template-parts/content-product-card.php
// This file contains the HTML and PHP for the product card layout

The same product card template part can be called on the homepage, the shop archive, and a “Featured Products” section — all referencing the same file.

2. Block Theme: Header Template Part

A block theme stores the header in /parts/header.html. Using the Site Editor, an editor opens the header template part, updates the navigation menu items, and saves. The change appears across every page on the site automatically — no page-by-page updates needed.

3. Hybrid Theme: Block-Based Sidebar

A classic theme is updated to support block-based template parts (available since WordPress 6.1). The developer adds a sidebar.html file to the /parts folder and registers block template part support in functions.php. Editors can now manage the sidebar’s widget areas visually in the block editor while the developer retains PHP control over the rest of the template structure.

Common Mistakes to Avoid

  • Hardcoding repeated content in every template file — Writing the same header HTML in every template file instead of using get_header() or a template part means every update must be made in multiple places. This is one of the most common mistakes in theme development that makes maintenance significantly harder over time.
  • Not organizing template parts in a subdirectory — For complex themes, placing all template part files in the root theme directory creates clutter. Use a template-parts/ subdirectory to keep files organized by type or purpose.
  • Confusing template parts with block patterns — Template parts are structural components (headers, footers, sidebars) that appear consistently across pages. Block patterns are reusable layout suggestions for content areas that can be inserted and customized on individual pages. Both have their place, but they serve different purposes.
  • Forgetting to register block template parts in classic themes — When adding block-based template parts to a classic theme (WordPress 6.1+), you must declare add_theme_support('block-template-parts') in functions.php. Without this, WordPress won’t recognize the /parts folder.

Best Practices

1. Give Template Parts Descriptive, Consistent Names

Use naming conventions that make the purpose of each template part immediately clear: header-with-banner.html, footer-minimal.html, content-service-card.php. Consistent naming makes it easier for developers to understand the theme structure and for editors browsing the Site Editor to find the part they want to edit.

2. Keep Template Parts Focused

Each template part should do one thing well. A header template part contains the header. A post meta template part contains the author, date, and categories. Avoid creating “kitchen sink” template parts that contain unrelated elements — they become hard to reuse and harder to maintain. The same principle of separation of concerns that applies to good PHP code applies to template parts.

3. Test Template Part Changes on a Staging Site First

Changes to template parts propagate to every page using them — which means a mistake in a template part affects the entire site at once. Before editing a template part on a live site (especially the header or footer), test the change on a staging site first to verify the result before it reaches real visitors.

Frequently Asked Questions

What is the difference between a template and a template part?

A template is the full page layout for a specific content type — the single post template, the category archive template, the homepage template. A template part is a component used within templates — the header, footer, sidebar, or a reusable content block. Templates define the overall structure; template parts define the reusable pieces within that structure.

Can site editors change template parts without developer help?

In block-based themes, yes. The WordPress Site Editor exposes template parts for visual editing — editors can update headers, footers, and other parts without writing code. In classic PHP themes, template parts are code files that typically require developer access to modify. The move toward block themes is specifically intended to give non-developers more control over site structure.

Are template parts the same as widgets?

No. Widgets are small, self-contained content elements (like a recent posts list or a search box) that are placed in widget-ready areas defined by a theme. Template parts are structural layout files that make up the theme itself. Widgets live inside template parts (like a sidebar template part that contains widget areas), not the other way around.

Do template parts affect site performance?

Properly implemented template parts have no negative performance impact — they’re just PHP includes or HTML files loaded at render time. In fact, they improve maintainability (which leads to cleaner code and fewer bloated files) and make it easier to keep templates lean. A bloated template part that includes unnecessary scripts or markup could affect performance, but that’s a content issue, not a structural one.

Related Glossary Terms

How CyberOptik Can Help

As a WordPress-focused agency, template parts are part of every theme we build — whether it’s a classic PHP theme or a modern block-based site. If your current theme has inconsistent headers across pages, a footer that’s a nightmare to update, or structural elements that require developer access for routine changes, we can rebuild the template architecture to make maintenance easier. Get in touch to discuss your project or explore our WordPress development services.