admin管理员组

文章数量:1403438

I am developing a block theme.

parts/sidebar.html templates/index.html

Sidebar Template is include like this —

parts/sidebar.html has this HTML —

<!-- wp:group {"className":"sidebar"} -->
<div class="wp-block-group sidebar"></div>
<!-- /wp:group -->

I am new to Block Theme Development and I am completely Clueles how to make inside of this area: <div class="wp-block-group sidebar"></div> block ready, which means "+" sign should appear while editing template.

I am developing a block theme.

parts/sidebar.html templates/index.html

Sidebar Template is include like this —

parts/sidebar.html has this HTML —

<!-- wp:group {"className":"sidebar"} -->
<div class="wp-block-group sidebar"></div>
<!-- /wp:group -->

I am new to Block Theme Development and I am completely Clueles how to make inside of this area: <div class="wp-block-group sidebar"></div> block ready, which means "+" sign should appear while editing template.

Share Improve this question asked yesterday WordCentWordCent 1,8916 gold badges34 silver badges60 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

There are two steps to adding a template part.

  1. Define it in theme.json.

You should already have something similar to this:

    "templateParts": [
        {"area": "header", "name": "header", "title": "Header"},
        {"area": "footer", "name": "footer", "title": "Footer"}
    ]

Just add another line for the sidebar:

    "templateParts": [
        {"area": "header", "name": "header", "title": "Header"},
        {"area": "footer", "name": "footer", "title": "Footer"},
        {"area": "sidebar", "name": "sidebar", "title": "Sidebar"}
    ]
  1. Add the file for the default block content.

This is the part you've done already - created parts/sidebar.html.

With both pieces in place, when you go to Appearance > Editor, choose Patterns, and then choose All template parts, you should now see your sidebar. (If not, either clear your cache or do a hard refresh.) Edit it and you'll be able to add blocks inside the group you've defined.

本文标签: How to Make an area in BlockTheme Block Insertable