localwebadvisor
WIKI← Wiki home

What Is a WordPress Page Template?

By FayUpdated Jul 10, 2026EVERGREEN
⚡ THE ANSWER

A WordPress page template is a theme file that controls the layout of a page, letting different pages look different within the same site. Every page uses some template; by default it is the theme's page.php, but a theme can offer named templates you pick from a dropdown in the editor. WordPress also follows a template hierarchy, choosing files automatically based on the page's slug or ID, so developers can style specific pages without editing every one by hand.

Definition
A theme file that determines a page's structure and layout (WordPress Developer docs)
Default file
Without a custom template, pages render through the theme's page.php file (WordPress Theme Handbook)
Custom templates
A special comment header registers a template so it appears in the editor's Template dropdown
Hierarchy naming
Files like page-{slug}.php or page-{id}.php target one specific page automatically
Block themes
Modern block themes define templates as HTML files edited visually in the Site Editor

What a page template controls #

A page template is the theme file responsible for how a single page is built and displayed. When someone visits a page on your site, WordPress does not invent the layout on the spot; it loads a template file that defines where the header, content, sidebar, and footer go, and wraps your written content inside that structure. By default every page uses the theme's page.php, so all pages share one look. Page templates matter because real sites need variety: a contact page may want a wide layout with a map, while a landing page wants no navigation or sidebar to keep visitors focused. Templates make that possible without duplicating content or bolting on page builders for every layout tweak. Understanding them is core to clean /services/wordpress-development, because the right template keeps design consistent and code maintainable. When a page looks wrong or ignores your design, the cause is almost always which template WordPress chose to render it. Spotting which template rendered a page is the fastest way to diagnose a layout that does not match your intended design.

The default template and the hierarchy #

WordPress decides which file renders a page using its template hierarchy, an ordered set of rules. For a standard page it looks, in order, for a template assigned in the editor, then page-{slug}.php, then page-{id}.php, then the generic page.php, and finally index.php as a last resort. The first matching file wins. This means you can style one specific page, say the About page, by creating page-about.php, and WordPress uses it automatically without any setting. The hierarchy is the same logic that gives posts, categories, and archives their own templates. Knowing it turns guesswork into control: instead of adding conditional code to page.php, you name a file precisely and WordPress routes to it. This system is elegant but invisible, which is why layout surprises during a /services/website-migrations project often trace back to a hierarchy file that existed on the old site but was not carried over, leaving a page to fall back to a plainer default. When a layout looks wrong only on one page, checking the hierarchy for a matching file usually reveals why.

Creating a custom page template #

A custom page template is a theme file with a special comment at the top that names it, so it shows up in the editor's Template dropdown for any page. The example below creates a full-width template with no sidebar. Once saved in the theme, editors can assign it to any page from the Page Attributes or Template panel, and that page instantly adopts the new layout while others stay unchanged. The get_header and get_footer calls pull in the site's shared header and footer, so only the middle changes. This approach is far cleaner than duplicating markup or forcing a page builder onto every page. It also travels with the theme, which matters during a /services/website-redesign when you want layouts to move as a unit. Custom templates are the professional way to give sales pages, portfolios, or checkout flows distinct structures while keeping one coherent codebase that a developer can update in a single place rather than page by page.

Example
<?php
/*
 * Template Name: Full Width Landing
 */
get_header(); ?>

<main class="full-width">
  <?php
  while (have_posts()) {
    the_post();
    the_content(); // outputs the page's editor content
  }
  ?>
</main>

<?php get_footer(); ?>

Template Name versus filename targeting #

There are two ways to apply a custom layout, and mixing them up causes confusion. The first is a named template using the Template Name comment header, which appears as a choice in the editor and can be assigned to any page you like. The second is filename targeting through the hierarchy, where a file called page-contact.php automatically styles only the page whose slug is contact, with no dropdown selection needed. Named templates are reusable across many pages; hierarchy files bind to one specific page. Use a named template when several pages should share a special layout, like a family of landing pages, and use a hierarchy file when exactly one page needs unique treatment. Choosing the right method keeps a theme tidy and predictable. When a page mysteriously ignores the layout you assigned, the usual culprit is a hierarchy file quietly overriding your dropdown choice, since automatic filename matches can take precedence and surprise even experienced editors who forgot the file existed.

Page templates versus the Block Editor #

Since the Block Editor arrived, some layout work that once required a PHP template now happens inside the editor itself. You can build multi-column sections, hero areas, and call-to-action blocks visually on a normal page without touching template files. This blurs the line for newcomers who wonder whether they need a template at all. The honest answer is both have a place. The Block Editor shapes content within the template's frame, while the template controls the frame itself, whether there is a sidebar, how wide the content runs, and what surrounds it. For a single distinctive page, blocks alone may suffice; for a layout you will reuse or that must strip the sidebar entirely, a template is cleaner and more reliable. Sites built for clear conversion through /services/conversion-optimization often combine both: a focused full-width template plus carefully arranged blocks inside it. Knowing where the template ends and content begins prevents you from fighting the editor to force a structural change.

How block themes changed templates #

Newer block themes redefine what a template is. Instead of PHP files, they store templates as HTML files inside a templates folder, and you edit them visually through the Site Editor rather than in code. The same hierarchy concept still applies, a template can target pages, single posts, or archives, but the editing experience is drag-and-drop, and the header and footer become editable template parts too. This lowers the barrier for site owners who want to adjust structure without a developer, though it also introduces a learning curve for anyone used to classic PHP themes. Both styles coexist across the WordPress world in 2026, and choosing between them shapes how a site will be maintained. Agencies planning long-term /services/care-plans weigh this carefully, because a block theme empowers clients to self-edit layouts while a classic theme keeps tighter developer control. Neither is universally better; the right choice depends on who will manage the site and how often layouts need to change.

Common page template problems #

A handful of issues account for most template trouble. The most frequent is a page falling back to the wrong file because the intended template was not assigned, or a hierarchy file was deleted during a theme edit, leaving a plain default layout. Another is editing a template directly in a parent theme, so a theme update overwrites the changes; using a child theme prevents this. Registering a Template Name comment with a typo stops the template from appearing in the dropdown. Copying a template between themes without adjusting its function calls can cause missing headers or footers. Hard-coding content into a template instead of letting editors manage it through the page also frustrates non-technical staff. These snags are exactly the kind of thing a /services/website-rescue engagement untangles. Building templates carefully, testing each page after changes, and using a child theme for edits avoids the layout surprises that plague sites assembled in a hurry or handed between developers.

Getting page layouts right for your site #

Page templates are the quiet backbone of a well-organized WordPress site, deciding whether every page shares one look or specific pages get purpose-built layouts. For most small businesses, a handful of templates, a standard page, a full-width landing page, and perhaps a contact layout, covers real needs without overcomplicating the theme. The goal is a system where editors can build content freely inside a stable, well-designed frame, and where a developer can adjust that frame in one file rather than page by page. Whether you use classic PHP templates or a modern block theme, the principle holds: structure lives in templates, content lives in pages. If your site's layouts feel inconsistent or a page refuses to match your design, that mismatch usually starts here. A short /free-website-audit or a conversation through /contact can identify whether your templates are working with you or against you before small layout annoyances grow into a bigger redesign project. Small template discipline early prevents the sprawling, inconsistent layouts that make later maintenance slow and frustrating for everyone involved.

FAQ

How do I assign a template to a page?

Open the page in the editor, find the Page Attributes or Template panel, and pick a template from the dropdown. Only templates that include a Template Name comment header in the theme appear there. Save the page and it adopts the new layout. If the dropdown is empty, the theme offers no named custom templates.

What is the difference between a template and a page?

A page is the content you write, stored in the database, while a template is the theme file that decides how that content is laid out and displayed. One template can format many pages. Think of the template as the frame and the page as the picture that goes inside it.

Why does my page ignore the template I chose?

Often a hierarchy file like page-{slug}.php exists and automatically overrides your dropdown choice, because filename matches take precedence. A caching plugin can also serve an old version. Check whether a specific template file targets that page's slug or ID, clear your cache, and confirm the assignment saved correctly in the editor.

Do I need a custom template for every page?

No. Most pages happily share the theme's default page.php, and the Block Editor handles a lot of layout variety within it. Create a custom template only when several pages need a distinct structure, like a full-width landing page with no sidebar, or when one page requires a truly unique frame.

Where are page template files stored?

In classic themes they live in the active theme's folder as PHP files, often at the top level or in a page-templates subfolder. In block themes, templates are HTML files inside a templates folder and are edited visually through the Site Editor. Always edit through a child theme so updates do not overwrite your work.

Will changing templates affect my content or SEO?

Switching a template changes layout, not the underlying content or URL, so your text and page address stay the same. That means SEO impact is usually minimal, though layout affects speed and user experience, which do matter. Test the page after changing templates to confirm headings, images, and internal links still display correctly.

How Local Web Advisor checks this for you

Is your own website getting web dev right?

Our free AI audit scans your site and tells you — in plain English — exactly what to fix for web dev and seven other areas, with the business impact and the fix for each. No login needed to start.

Run my free website audit →

Was this helpful?