Exercise: Adding Header and Footer template parts

Create the template parts

Step 1: Create the header

  1. Add a Header block as first block in the template.
  2. Choose Start Blank
  3. Name the template part Header.
  4. Move the Site Title block inside of the Header block

Step 2: Create the footer

  1. Add a Footer block as first block in the template.
  2. Choose Start Blank
  3. Name the template part Footer.
  4. Add a paragraph with Proudly powered by WordPress.

Step 3: Export the theme


Register the template parts

  1. Add a templateParts key at the root of theme.json. Use an array as the value.
  2. Add an object for each template part containing:
    1. area: header or footer.
    2. name: Name of the template part file, so header or footer.
    3. title: Name shown in the interface, so Header or Footer.
  3. 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