Design System WordPress Theme
Home
Github
Home
Github
  • Site Editor

    • Patterns

      • How to use patterns
        • DSWP Card With Hyper Link List
        • DSWP Vertical Cards
        • DSWP Default Heading
        • DSWP Footer With Territorial Acknowledgement
        • DSWP Heading with Paragraph(s)
        • DSWP Horizontal Card No Shadow
        • DSWP Icon with Excerpt
        • DSWP Hero Image with Title
        • DSWP Horizontal Card
        • DSWP Horizontal Card Large Image Left
        • DSWP Horizontal Card Large Image Right
        • DSWP Image And Text
        • DSWP Image And Text Flipped
        • DSWP Information Contact Socials
        • DSWP Link With Arrow
        • DSWP Secondary Hero Image With Title
        • DSWP Team Pattern
        • DSWP Vertical Cards With Icon
      • Patterns Overview
  • Developers

    • Patterns Troubleshooting
    • Template Parts

Template Parts

How to Add a Template Part by Category

To add a template part, create an .html file in the parts folder that represents your template part. For example, let's create a header template part called header-site-title.html.

Getting Started with a Template Part

Step 1: Create the Look and Layout

Create the look and layout you want inside a group block.

Step 2: Copy the Code

Switch to code view and copy the code to your clipboard.

Step 3: Paste the Code

Paste the code into your .html file.

Alternative Source of Starter Template Parts

You can also use the WordPress pattern directory as a source of starter template parts: https://wordpress.org/patterns/

Registering the Template Part

Once the code is added to your template part .html file, edit the theme.json file to register the template part.

Example: Adding a Header Template Part

Here's an example of how to add multiple headers to the header category of the template parts for the site editor:

"templateParts": [
  {
    "name": "header-no-site-title",
    "title": "Header No Site Title",
    "area": "header"
  },
  {
    "name": "header-site-title",
    "title": "Header Site Title",
    "area": "header"
  },
]
Contributors: ASpiteri-BCGov
Prev
Patterns Troubleshooting