admin管理员组

文章数量:1122826

I have two working blocks hero Carousel and hero Carousel Slide. When I hard code these blocks in the template file they do not appear nested in the editor. In the editor, I am able to drag and drop the child block into the parent block as well as use the + icon to add the child block into the parent. How does one invoke blocks with nested blocks in a template file, when creating a bespoke theme.

in front-page.html

<!-- wp:mytheme/herocarousel /-->
  <!-- wp:mytheme/herocarouselslide /-->
<!-- /wp:mytheme/herocarousel /-->

I have two working blocks hero Carousel and hero Carousel Slide. When I hard code these blocks in the template file they do not appear nested in the editor. In the editor, I am able to drag and drop the child block into the parent block as well as use the + icon to add the child block into the parent. How does one invoke blocks with nested blocks in a template file, when creating a bespoke theme.

in front-page.html

<!-- wp:mytheme/herocarousel /-->
  <!-- wp:mytheme/herocarouselslide /-->
<!-- /wp:mytheme/herocarousel /-->
Share Improve this question edited Jun 11, 2024 at 23:08 pjbrusven asked Jun 11, 2024 at 22:44 pjbrusvenpjbrusven 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

If you insert things the way you want in the editor and then copy and paste them you'll get the correct output.

The mistake you've made here is the / closing the block comment:

<!-- wp:mytheme/herocarousel /-->

Should be:

<!-- wp:mytheme/herocarousel -->

Only use /--> if the block has no content or children.

本文标签: Hard code block with nested block in frontpagehtml template