The Template Part block is an advanced block introduced in WordPress 5.9 that can be used with a block theme or a theme that supports template editing. They often come with your theme and are used to organize and display your site structure. You can only use them while creating and editing templates to manage blocks in areas repeated across the website. For context, this block is best used to create areas like your site header and site footer. When you change blocks inside a template part, the editor updates the blocks on every block template that includes the template part.
In order to add a Template Part block, click on the add block button and select the Template Part block. You can also type “/template part” and hit enter in a new paragraph block to add one quickly. In many cases, you’ll also see options to select types of Template Part blocks, like Header and Footer when searching for this block. You can search for the header or footer in the block inserter to insert the blocks or use the shortcuts “/header” and “/footer”.
Detailed instructions on adding blocks can be found here.
Adding template parts
You can add templates when using the Template Editor or Site Editor to edit templates directly. After adding a template part, you can choose from existing parts or create a new template part:
![Template part block provides two buttons: "choose" and "start blank".](https://wordpress.org/documentation/files/2023/08/adding-template-part-block.png)
Choosing from existing template parts
Selecting the button “Choose” opens a modal where you can search, preview, and select existing parts. These parts will depend on what your theme has provided:
![Using the "choose button", existing template parts can be selected.](https://wordpress.org/documentation/files/2023/08/choosing-template-part-1024x752.png)
Creating new template parts
Selecting “Start blank” will prompt you to add a name. It’s best to pick a descriptive name so that it’s easy to find in the future:
![When we create a new template part block, we get a field to edit the name and options to create or cancel.](https://wordpress.org/documentation/files/2022/01/Screen-Shot-2022-01-05-at-12.12.43-PM.png)
Creating new template parts from the template part list
If you are using a block theme, you can also create a new template part from the template part list in Administration Screen > Appearance > Editor > Patterns > Template Parts. Click on the Create patterns icon to find Create template part:
![Template part list area also provides an option to create template part.](https://wordpress.org/documentation/files/2023/08/creating-new-template-part-770x1024.png)
When you select the Create template part, a modal appears where you can add a name and select the area for the template part. You must provide a name in order to create a new template part:
![Upon clicking on create template part, a pop up appears with the title "Create a template part".](https://wordpress.org/documentation/files/2022/01/Screen-Shot-2022-01-05-at-12.19.00-PM-982x1024.png)
Managing template parts and patterns
At the bottom of the patters screen, there is an option to manage template parts. This is a new feature for block patterns that can be saved and synced across the site. It renames the existing Reusable block
block type to Pattern
and adds a source
property to distinguish core and user patterns.
![At the bottom of template part list, there is a link named "manage all template parts" which opens this list of template parts.](https://wordpress.org/documentation/files/2023/08/managing-template-parts-1024x355.png)
Customizing template parts
After adding or selecting a Template Part block, you can customize in various ways by adding additional blocks within it. To make it easier to find current template parts to edit, it’s recommended that you use one of the following options:
- Use List View when you’re editing a template to quickly identify the Headers and Footers in your content to edit.
- Use the template part focus mode described below.
Template part focus mode
To make it easier to focus specifically on editing a single template part, like a Header or Footer, you can use a dedicated mode that only shows an individual template part. There are a few ways to access this mode:
- Select the template part in the Site editor > Click on the three dot menu > Select “Edit Header” or the respective template part name.
- Select the template part in List View > Click on the three dot menu > Select “Edit Header” or the respective template part name.
- From the Browsing sidebar > Navigate to Template Parts > Select the template part you want to customize.
- From the Top Toolbar > Click on the three dot menu under “Areas” next to the template part you want to customize.
Here’s a video demonstrating one of the ways to access this mode:
Replacing one template part with another
If the theme has more than one template part for the same area, you can use the Replace option in the block toolbar to replace the current template part with another. If you don’t see this option, this is because the theme hasn’t provided multiple template parts for the same area.
![Image showing the option to replace a current template part.](https://wordpress.org/documentation/files/2022/01/Screen-Shot-2022-01-05-at-1.11.35-PM-1024x717.png)
Advanced Settings
Under Advanced settings, you can rename the template part and select an area: General, header, or footer. The panel also lets you change the HTML element and add CSS class(es) to your block. You can choose between these HTML elements: Div, header, footer, main, section, article, and aside.
![Image of advanced options with the template part block.](https://wordpress.org/documentation/files/2022/01/Screen-Shot-2022-01-05-at-12.30.36-PM.png)
Changelog
- Created 2022-01-05
- Updated on August 4th, 2023
- Sort template parts by type in navigation screen.
- I have added screenshot that depicts the sorting under a new section that I created i.e Creating new template parts from the template part list
- Add corresponding area icon to template part menu items.
- I noticed the library has been replaced by Pattern so the screenshot from the section Creating new template parts from the template part list covers this as well.
- Library: Rename template parts to library.
- I noticed this PR is dated as May 19th and the one 52102 was on June 29th so I am assuming the one dated with June 29th is the latest one. Is that correct?
- Add chevrons to the templates and template parts in site editor and
- Change “Browse all templates” to “Manage all templates” in template details popover
In the section Creating new template parts from the template part list, the screenshot shows chevron icons on the left of patterns and on the right of manage all template parts and manage all patterns. Since there is no description of template, I didn’t add screenshot for template’s chevron icon. In the same screenshot, the manage all template parts is shown.
- Add “Added by” description to template part navigation sidebar
I created this section Managing template parts and patterns, and there I added a screenshot that shows the Added by for template parts.
- Update Template Parts icon to use the symbol
I updated the screenshots to show the latest Template parts icon
Was this article helpful? How could it be improved?
Log in to submit feedback. If you need support with something that wasn't covered by this article, please post your question in the support forums.