Exercise: Adding Header and Footer template parts
Create the template parts
Step 1: Create the header
- Add a Header block as first block in the template.
- Choose Start Blank
- Name the template part Header.
- Move the Site Title block inside of the Header block
Step 2: Create the footer
- Add a Footer block as first block in the template.
- Choose Start Blank
- Name the template part Footer.
- Add a paragraph with Proudly powered by WordPress.
Step 3: Export the theme
Register the template parts
- Add a
templateParts
key at the root of theme.json
. Use an array as the value. - Add an object for each template part containing:
area:
header
or footer
.name:
Name of the template part file, so header
or footer
.title:
Name shown in the interface, so Header
or Footer
.
- Reload the Site Editor, and check that the template parts have the right area, and the right icon.
Test and Verify
Blocks in Site Editor
Theme.json
Complete and Continue