This feature is available with all block themes.
Theme developers can opt-in to add it to classic themes.
Level: Beginner, no code
Estimated reading time: 5 minutes
Templates are designs for pages and posts. They let you select different designs for different content. Templates are optional and you decide if you want to use or create a custom template.
While only developers can create traditional page templates with code, anyone can create a block template using a full site editing theme.
You create full site editing templates using blocks. -If you are already familiar with block patterns, think of a template like an extra-large pattern, where the post content is one block.
Limitations with templates today
-Let’s look at some of the problems that full site editing is trying to solve:
Only theme developers can create and edit traditional templates
If you have a theme with a sidebar but would like to remove the sidebar from one page, you need to know the code to hide the sidebar.
You can not preview templates before you select them
You select a traditional template by opening a post or page and selecting a template from the Page Attributes Template section. All you have to go by is the name:
You can not see what the template looks like when adding and editing content
You can only see the full page by viewing the website on the front, not in the editor.
Improvements to templates with full site editing
Themes can now include two types of templates:
- The traditional page template that you can not edit without code. Existing templates will not change. Post and pages that use these templates will not change or break.
- A full site editing block template that you can edit.
There are two ways to edit block templates without code:
- The template editor, which is a part of the block editor since WordPress 5.8.
- The site editor. An advanced template editor only available with the Gutenberg plugin. This editor will be included in the next version of WordPress, 5.9.
Both editors let’s you view and edit the full site editing template including site header, content and footer.
You can replace or move blocks directly in your header area, add a header image, upload a new site logo, or change colors. Or why not add new social links or place your contact information and copyright in the site footer?
The template editor
The template editing mode is part of the block editor, and is built only for viewing and editing single pages and posts.
Once you have opened a page or post in the block editor, you access the template editor from a new section in the document sidebar called Template:
Creating your own template
Clicking the “New” link in the template section will create a new template for your current page.
See the full page template when writing your content
Clicking the “Edit” link in the template section opens the template editing mode. This editor is very similar to the block editor, the difference is that you are viewing the full page.
Here is what this page looks like in the template editing mode using Gutenberg 10.7.1:
-The dark grey border is part if the editor, and is added so that we can easily see the difference between the block editor and template editor.
At the top, you can see the header area with the site title block, navigation menus and search. Below that is the content block. This is the same content that is in the block editor.
In this view, you can save changes to both the content and the template.
When you select a single block, the block has the same options as in the block editor.
There is also a special block called template part that is only available in the template and site editor.
To return to the editor, you can select the back button.
Coming soon -Site editor
The site editor is a new interface in WordPress 5.9 where you can select, preview and edit all templates and template parts. This is where you will customize your blog, archives, 404 page, and search results.
Coming soon –Preview templates before assigning them
This feature is still under development. The goal is that you will be able to select a template from a preview and not only a name. Here is one of the proposed designs for the template preview: