Setup & site building · Guide
How to Create a WordPress Template (Block and Classic Themes)

Short answer
To create a WordPress template in a block theme, go to Appearance > Editor > Templates, click Add New Template, choose a template type or Custom Template, design it with blocks and save. Then assign it to a page in the page settings sidebar. In a classic theme, you create a PHP template file in a child theme instead.
Key takeaways
- Templates control the layout of a type of page, while your content stays in the post or page itself.
- Block themes let you create templates visually in the Site Editor without code.
- Templates made in the Site Editor are stored in the database until you export them to theme files.
- Classic themes need a PHP template file, ideally inside a child theme so updates do not erase it.
- Template parts like headers and footers let several templates share the same sections.
What is a template in WordPress?
A template is a layout that decides how a type of page looks, such as single posts, archives or one specific page, while the text and images come from the content you write.
Think of it as the frame around your content. The single post template might show a featured image, the title, the content and related posts. Every post uses that frame automatically.
WordPress picks which template to use through the template hierarchy. For example, a page with the slug “contact” looks for a page-contact template first, then the general page template, then the index.
Templates are different from patterns. A pattern is a group of blocks you insert into content, while a template wraps the whole page around that content.
Do you have a block theme or a classic theme?
Check under Appearance: if you see an Editor menu item, you have a block theme and can create templates visually; if you see Customize instead, you have a classic theme.
The method depends entirely on this. Block themes store templates as block markup and let you build them in the Site Editor. Classic themes use PHP files that you edit in code.
If you are choosing a theme now and want to make templates without code, pick a block theme. Our guide to block themes vs classic themes compares the two in detail.
How do you create a template in the Site Editor?
Open Appearance > Editor > Templates, click Add New Template, pick the type of template or Custom Template, then design it with blocks and save.
Step by step:
- Go to Appearance > Editor and choose Templates
- Click Add New Template (the plus icon next to the Templates heading)
- Choose a template type, such as Single item: Post, Page, Category or Author
- Or choose Custom Template and give it a clear name, such as “Landing page no sidebar”
- Pick a starting pattern or start blank
- Add blocks: header, Post Title, Post Featured Image, Post Content and footer
- Click Save
The theme handbook on templates explains that new templates you add in the editor are saved in the database, not in your theme files.
Make sure the template includes a Post Content block or Content block. Without it, pages using the template will not show the text you write.
Which blocks should a template include?
A working template needs a header, the dynamic content blocks for that page type, and a footer, while fixed text belongs in patterns or the content itself.
Use these as a starting checklist:
| Template type | Key blocks |
|---|---|
| Single post | Post Title, Post Featured Image, Post Date, Post Content, Comments |
| Page | Post Title, Post Content |
| Archive or category | Query Title, Query Loop with Post Template, Pagination |
| Search results | Search, Query Title, Query Loop, No Results |
| 404 | Heading, Paragraph, Search |
| Custom landing page | Header, Post Content, Footer, no sidebar |
The Query Loop block lists posts on archive templates. It inherits the query from the page by default, so a category template shows posts from that category automatically.
When should you make a new template instead of editing a page?
Make a new template when several pages need the same layout, and edit the page itself when only one page needs a different look.
A template is worth creating when the layout repeats. Good examples are landing pages without a sidebar, a wide layout for long guides, a distinct design for one post category, or an author page with a bio box.
For a single page with unique sections, build those sections inside the page with blocks and patterns instead. Too many custom templates make a site harder to manage, since every future design change has to be repeated in each one.
A few naming habits help later:
- Name templates by purpose, such as “Landing page” or “Guide, wide”, not by date
- Keep one template per layout, not one per page
- Note in the template name if it hides the header or footer
- Delete custom templates no one uses any more
The template editor has been part of WordPress since version 5.8, when it was introduced for creating page templates with blocks. Many older tutorials still describe only the PHP method, so check the date of any guide you follow.
How do you assign a custom template to a page or post?
Open the page in the editor, find Template in the page settings sidebar, pick your custom template and click Save or Update.
In the editor sidebar under the Page or Post tab, click the current template name. A list of available templates appears, including any custom ones you created.
You can also create a new template from the same menu. That option opens the template editor right inside the page, which is handy for one-off layouts.
A custom template can be assigned to as many pages or posts as you like. The Learn WordPress template editor lesson shows both ways of reaching the template editor.
How do you reuse headers and footers across templates?
Use template parts, which are shared sections such as the header and footer that update everywhere at once when you edit them.
In the Site Editor, open Patterns and look for template parts, or add a Template Part block inside any template. Editing the part in one template changes it in every template that uses it.
Create a separate header part when a template needs a different header, such as a minimal header for landing pages. Our guide on editing the header in a block theme covers this.
The documentation on patterns, template parts and synced patterns explains when to use each.
How do you create a template in a classic theme?
In a classic theme, create a PHP file with a Template Name comment at the top, place it in a child theme, and it will appear in the page template menu.
A minimal page template file starts like this:
<?php
/*
* Template Name: Full Width No Sidebar
*/
get_header();
while ( have_posts() ) : the_post();
the_content();
endwhile;
get_footer();
Save it as a file such as template-full-width.php in your child theme folder. Never add it to the parent theme, as the next theme update would delete it.
Our guide on child themes shows how to set one up.
For more examples, see our walkthrough on creating a custom page template.
How do you save a Site Editor template into your theme files?
Export it, either by downloading the whole theme from the Site Editor menu or with the Create Block Theme plugin, so the template lives in files you can version and reuse.
Templates made in the Site Editor live in the database. That is fine for one site, but you lose them if you switch themes or need them on another site.
The free Create Block Theme plugin saves your editor changes into the theme's templates folder as HTML files. You can also register template names and post types in theme.json, as our guide to using theme.json explains.
Keep an export as a backup before large design changes, and store a copy outside the site, such as in a Git repository. It is the easiest way to roll back a template you did not mean to change.
What if your template does not show up or will not apply?
If a template is missing or ignored, check that you are using a block theme, that the template is saved, and that a more specific template is not overriding it.
Common causes and fixes:
- Custom template not in the page menu: it may be set for a different post type, or the theme does not support custom templates
- Changes not visible: clear your caching plugin and CDN cache
- Wrong template used: a more specific template in the hierarchy, such as page-about, wins over the general one
- Content missing: the template has no Post Content block
To undo edits to a theme's built-in template, open its menu in the Templates list and choose to reset or clear customizations.
Frequently asked questions
Can I create a WordPress template without coding?
Yes, if you use a block theme. The Site Editor lets you create templates with blocks and assign them to pages without writing code. Classic themes need a PHP template file, so they do require some coding.
What is the difference between a template and a pattern in WordPress?
A template controls the layout around a page's content, such as the header, title and footer. A pattern is a ready-made group of blocks you insert into content or templates. Templates apply automatically, patterns are added by hand.
Where are WordPress templates stored?
Theme templates are files inside the theme folder. Templates you create or edit in the Site Editor are saved in the database as their own entries, until you export them back into theme files.
Will my custom template survive a theme update?
Templates saved in the Site Editor are stored in the database, so a theme update does not overwrite them. PHP template files added directly to a parent theme are lost on update, which is why child themes exist.
Can I use one template for many pages?
Yes. You can assign the same custom template to as many pages or posts as you like, and changing the template updates the layout of all of them at once.
Sources
- Templates WordPress Theme Handbook
- Template Hierarchy WordPress Theme Handbook
- Template Editor lesson plan Learn WordPress
- Comparing Patterns, Template Parts, and Synced Patterns WordPress.org Documentation
- Registering block templates via plugins in WordPress 6.7 WordPress Developer Blog
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


