Skip to content

Plugin-registered block template title and description missing when overwritten by theme #64576

@justintadlock

Description

@justintadlock

Description

With the changes in #61577, it's possible to register a block template via a plugin. As you can see in the screenshot below, I registered a few templates. Take particular note of the example template and its name and description:

image

If I then overwrite this from a theme via /templates/example.html, the Title field uses the template name and the Description field is missing:

image

Step-by-step reproduction instructions

Step 1: Register a block template (Code below is for a plugin named devblog-plugin-templates):

add_action( 'init', 'devblog_register_plugin_templates' );

function devblog_register_plugin_templates() {
	wp_register_block_template( 'devblog-plugin-templates//example', [
		'title'       => __( 'Example', 'devblog-plugin-templates' ),
		'description' => __( 'An example block template from a plugin.', 'devblog-plugin-templates' ),
		'content'     => '<!-- wp:template-part {"slug":"header","area":"header","tagName":"header"} /-->
			<!-- wp:group {"tagName":"main"} -->
			<main class="wp-block-group">
				<!-- wp:group {"layout":{"type":"constrained"}} -->
				<div class="wp-block-group">
					<!-- wp:paragraph -->
					<p>This is a plugin-registered template.</p>
					<!-- /wp:paragraph -->
				</div>
				<!-- /wp:group -->
			</main>
			<!-- /wp:group -->
			<!-- wp:template-part {"slug":"footer","area":"footer","tagName":"footer"} /-->'
	] );
}

Step 2: Verify title and description are correct in the UI

Title should be should be Example, and description should be An example block template from a plugin in the Templates UI.

Step 3: Overwrite example.html in a theme

Create a /templates/example.html template in a theme with whatever block markup you want.

Step 4: Check template title and description

Now you should see a template titled example with no description and listed under your theme in the Templates UI.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress trunk
  • Gutenberg trunk

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Metadata

Metadata

Assignees

Labels

[Feature] Templates APIRelated to API powering block template functionality in the Site Editor[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions