ZeroToWP

Template

Quick Definition

A template is a file in your WordPress theme that controls how a specific type of content is displayed. WordPress uses a template hierarchy to automatically pick the right template for each page.

WordPress themes use templates to control how different types of content are displayed

What Is a Template?

A template is a modular, reusable file in your WordPress theme that generates a specific type of web page. According to the WordPress Theme Handbook, template files are PHP files (or HTML files in block themes) that WordPress uses to render different types of content.

Some templates appear on every page (like header and footer), while others only display under specific conditions — for example, single.php only loads when viewing a single blog post.

The Template Hierarchy

WordPress uses a template hierarchy to decide which template file to use for each page. It searches from most specific to least specific, using the first match.

For a post with slug "my-first-post", WordPress looks for:

  1. single-post-my-first-post.php
  2. single-post.php
  3. single.php
  4. singular.php
  5. index.php (ultimate fallback)

Main template types:

  • front-page.php — homepage
  • home.php — blog listing
  • single.php — individual posts
  • page.php — static pages
  • archive.php — archives
  • search.php — search results
  • 404.php — error page
  • header.php / footer.php — site-wide

Templates in Block Themes

In block themes, templates are HTML files in /templates/. Edit them visually in the Site Editor using blocks — no code required.

Why It Matters

Templates control your site's layout for different content types. See our best themes guide and theme selection guide.

Related Terms

Related Articles