Review of traditional templates and new templates

What is a template?

It is a file that describes what kind of HTML is used to display the post title, body text, metadata (post date and category), etc. created with the editor.

Traditionally it was in PHP format, but the newly added template is in HTML and is saved in a custom post type, which has the advantage of being all done in the editor.

I think the task of creating and customizing child themes as before will probably be a thing of the past, as the reliance on themes will be significantly reduced.

On the other hand, it seems that you may not be able to do what you were able to do with a template that combines a PHP format template and a short code or uses conditional branch tags in a complicated manner, but the original template hierarchy is completely changed. It doesn’t seem to be a replacement, so you might consider using traditional PHP templates wherever you need them.

In any case, it is becoming important to fully understand the differences between the current template hierarchy and the new template system and how it works.

Template hierarchy

Templates used for posts and pages have naming conventions that can be combined with specific post IDs, URL slugs, etc. to display specific posts using special templates. ..


If you create a template with comment lines added to the theme as shown below, you will be able to select the template on the theme post edit screen. By specifying the Template Post Type, you can select either a post or a fixed page.

 * Template Name: Gallery template
 * Template Post Type: post, page

Traditionally used PHP custom templates required creating a php file, creating a child theme and uploading it outside of WordPress, which was a hassle to create, but from WordPress 5.8 it’s an editor You will be able to create it from the menu.

You will see a link called’New’in the template item, but you can click this link to create a new template.

The template you create is saved in Appearance / Template. Keep in mind that this template will be saved as a template with the prefix wp-custom-template.

Template part file

Templates used in parts that make up part of the template, such as headers and footers.

Display the slug-name.php file by using the following function.

If slug-name.php does not exist, it will display slug.php.

get_template_part( $slug, $name );

Besides this, by adding an argument when calling the header or footer


If header-html5.php exists, the file will be displayed, and if it does not exist, header.php will be displayed.

In these templates, you can specify more detailed display conditions by using the conditional tag –WordPress Codex Japanese version.

Traditionally used PHP templates had to be created and uploaded outside WordPress, which was a hassle to create, but these templates are also in the Appearance / Templates and Appearance / Templates parts. , You can now create a new one.

You can edit and replace templates in the new site editor.

The created template can be called using the Template Part block, header block, footer block, etc. on the post edit screen.

WordPress 5.9 HTMLテンプレート

The template filter will now save the following templates to your custom post type. (As of WordPress 5.8)

$filter_list = array( 'embed_template', '404_template', 'search_template',
		  'frontpage_template', 'home_template', 'privacypolicy_template',
		  'taxonomy_template', 'attachment_template', 'single_template',
		  'page_template', 'singular_template', 'category_template',
		  'tag_template', 'author_template', 'date_template',
		  'archive_template', 'index_template', );

If you change the header or footer in the site editor, they are also saved as a template part file.

If you’re new to WordPress, it’s likely to be a “something messy” story, and it’s distracting, but the important part is that the main templates in the WordPress template hierarchy are replaced with HTML templates. However, not all template hierarchies are replaced.

If you don’t have to create a child theme, you may want to enable FSE on your existing site.

Let’s experiment.

Enable Gutenberg using TT1 blocks 0.4.7, a block editor-enabled theme. The core is WordPress 5.7.2.

Let’s add archive.php to the theme. Write the contents of the file as hello archive.

When I opened the appropriate category, I saw the hello archive in my environment.


I would like to switch the theme to emulsion and add archive.php to see if PHP templates are used.

Don’t forget to set the theme mode to FSE.

As a result, it is not displayed in the PHP template and there is no change in the display.

What makes this difference?

In order to display with PHP template, it is necessary to change the name of the template in the block-templates of the emulsion theme. If you try renaming category.html, archive.html to another name, the php template will be applied.

From this, you should understand that if there are several Full Site Editing compatible themes, they will produce different results.

Currently, site editor-enabled themes don’t have such PHP-based templates, so it may not cause any problems, but we not only create new sites, but also make current sites new. There are quite a few things that I want to migrate.

Testing is probably a must if you’re moving from an existing site to a new WordPress scheme.

For this reason, in the emulsion theme, the setting to display in the current theme, the setting to replace only the main part of the current theme, full (because it is difficult to verify the operation of the sidebar with the existing site editor compatible theme) This is the main reason for adding a filter so that it can be displayed in three modes of site editor display.

Templates are not only used by themes, but there are many plugins that use templates. I’m sure this weird theme will help you when checking compatibility with the plugins you use.