Skip to content

wp:post-content - templateLock to work inside page templates #60280

@SamTyurenkov

Description

@SamTyurenkov

What problem does this address?

Often Wordpress sites include a number of unique pages - homepage, policy, about, shop and some other with custom blocks on them.
And developers provide those pages as templates in block based themes, e.g. templates/page-about.html

<!-- wp:template-part {"lock":{"move":true,"remove":true},"slug":"header","area":"header","tagName":"header"} /-->

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

	<!-- wp:mytheme/container -->
		<!-- wp:post-title /-->
	<!-- /wp:mytheme/container -->

	<!-- wp:post-content -->
		<!-- wp:mytheme/news-filtered /-->
                <!-- wp:mytheme/my-other-block /-->
	<!-- /wp:post-content -->

<!-- wp:template-part {"lock":{"move":true,"remove":true},"slug":"footer","area":"footer","tagName":"footer"} /-->

Note how wp:post-content might be meant to use with specific blocks, for that specific template

What is your proposed solution?

I would expect something like that:

  • ability to add templateLock to wp:post-content and specify inner blocks.
  • in the editor, a notice to the user that he can reset template to the specified
  • on new page creation, if page has empty content and a page template is selected from sidebar - apply desired blocks on template enable
	<!-- wp:post-content {"templateLock":"all","lock":{"move":true,"remove":true}} -->
		<!-- wp:mytheme/news-filtered /-->
                <!-- wp:mytheme/my-other-block /-->
	<!-- /wp:post-content -->
	```

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions