Solution: Structured Stay Summary
A complete parent shell with two starting children, allowed-block rules, and an insertion lock.
This completes Control Child Blocks and Movement. Keep the flexible Content Section from the recipe and add this second shell.
Complete shell
1import { defineBlock } from "@forgewp/react"
2
3export default defineBlock({
4 name: "stay-summary",
5 title: "Stay Summary",
6 category: "design",
7 icon: "editor-alignleft",
8 innerBlocks: {
9 allowedBlocks: ["core/heading", "core/paragraph"],
10 template: [
11 ["core/heading", { level: 2, content: "Your stay at a glance" }],
12 ["core/paragraph", { content: "A comfortable base for exploring the coast." }],
13 ],
14 templateLock: "insert",
15 orientation: "vertical",
16 },
17 shell: {
18 className: "mx-auto max-w-5xl border border-slate-200 bg-white px-6 py-10 text-slate-900",
19 gridClassName: "grid gap-4",
20 },
21 edit: () => null,
22})Why it works
The parent supplies layout and the initial composition. WordPress stores each child's type, attributes, and content inside the parent's saved block tree.
allowedBlocks limits direct child choices to headings and paragraphs. templateLock: "insert" restricts normal child insertion and removal while allowing their order to change. The individual core blocks retain their text editing controls.
The initial template is a starting point for new instances. Preserve existing editor content when updating defaults, and test a freshly inserted shell when checking a new starting composition.
Compare the stricter variant
For the extension, replace the lock line with:
1templateLock: "all",This also restricts child reordering. It keeps the existing heading and paragraph text editable, subject to the surrounding editor's permissions and settings.
These controls shape the editing workflow. If you need to restrict operations on the whole parent, configure those at the Page or parent-block level separately.
Verify in WordPress
pnpm typecheck
pnpm forgewp export --validate --strict- Update the test theme and open a content-rendering Page.
- Insert Content Section and Stay Summary beside each other.
- Use List View to inspect their children. Add an image to Content Section and confirm the summary's normal child insertion/removal controls are restricted.
- Change the summary's heading and paragraph, reorder them, save, and reload.
- Confirm the text and order on the visitor page.
- Test the
"all"variant separately and compare its movement controls. - Repeat the intended configuration with the client's role.
For generated output, inspect the parent shell renderer and its $content insertion. The theme's generated editor configuration supplies allowedBlocks, template, and templateLock to Gutenberg's nested-block editor.
Return to Build a Section with Nested Blocks, or see Choose How Block Content Is Edited to compare shells with attribute-driven blocks.