WordPress Templates and Template Parts

Browse manual On this page × Wordpress Manual WordPress Fundamentals Toggle WordPress Fundamentals section What Is WordPress? WordPress.org vs WordPress.com What Can You Build with WordPress? How WordPress Works WordPress Core, Themes, Plugins and Content Essential WordPress Terminology How to Plan a WordPress Website Domains, Hosting, DNS and HTTPS Explained How to Choose WordPress Hosting…

3 min read

  • Article
  • Intermediate
  • 3 minutes read
  • Reviewed August 3, 2026

Templates define the document structure WordPress uses to display a request. Template parts represent smaller reusable regions that can be included in more than one template.

Together, they allow a theme to apply consistent layouts without rebuilding every page individually.

What a Template Controls

A template determines which elements appear and how they are arranged.

A single-post template might include:

  • Site header.
  • Post title.
  • Author and date.
  • Featured image.
  • Post content.
  • Taxonomy terms.
  • Comments.
  • Related content.
  • Site footer.

The post supplies the stored values. The template supplies the reusable structure around them.

Templates in Classic Themes

Classic themes use PHP template files.

Common examples include:

  • index.php.
  • home.php.
  • front-page.php.
  • single.php.
  • page.php.
  • archive.php.
  • search.php.
  • 404.php.

Template functions retrieve content and include shared files such as header.php, footer.php or sidebar.php.

Templates in Block Themes

Block themes use HTML files containing block markup, usually inside a templates directory.

Instead of hard-coding the current post title in PHP, a template includes a Post Title block. A Post Content block outputs the body of the current item, while Query Loop can display collections.

Users with appropriate access can edit these templates in the Site Editor. User customizations may be stored in the database and take precedence over theme files.

What Template Parts Are

Template parts are reusable structural sections included by templates.

Typical examples are:

  • Header.
  • Footer.
  • Sidebar.
  • Comment area.
  • Promotional strip.
  • Repeated archive header.

In block themes, template parts are block-based and often managed in the Patterns area of the Site Editor. In classic themes, shared PHP files serve a similar reusable role, even though the implementation differs.

Templates vs Page Content

Do not place unique page content in a template unless every page using that template should display it.

Use a template for structure and dynamic placeholders. Use the post or page editor for the unique information belonging to one content item.

A common mistake is placing a specific heading or call to action directly in the Page template and then wondering why it appears everywhere.

Templates vs Patterns

Templates define complete page structures. Patterns are reusable groups of blocks that can be inserted inside content or templates.

A template can contain one or more patterns. A pattern does not become the routing template merely because it fills a large part of the page.

User-Created Templates

WordPress can allow administrators to create custom templates through the Site Editor or Template Editor.

These templates are useful for alternative layouts such as:

  • Landing page without a title.
  • Full-width page.
  • Content with a sidebar.
  • Special campaign layout.

Plan names and ownership carefully. A large collection of nearly identical templates becomes difficult to maintain.

Template Maintenance

  • Keep template responsibilities clear.
  • Reuse template parts for repeated regions.
  • Avoid embedding unique content globally.
  • Test every primary content type and archive.
  • Document database customizations that override files.
  • Review templates after theme updates.
  • Maintain fallback behavior for content without a specialized template.

Frequently Asked Questions

Is a template the same as a page?

No. A page is a content record. A template is the reusable structure used to present that page and potentially many others.

Can several pages use one template?

Yes. That is one of the main purposes of templates.

Why does changing a theme file not update the site?

A user-edited template stored in the database may override the file. Caching can also delay visible changes.

Continue Learning

Previous: Navigation in WordPress

Next: The WordPress Template Hierarchy