[wp-trac] [WordPress Trac] #63808: Block hooks are not applied to plugin-registered templates using `register_block_template()`
WordPress Trac
noreply at wordpress.org
Mon Aug 11 13:00:06 UTC 2025
#63808: Block hooks are not applied to plugin-registered templates using
`register_block_template()`
--------------------------+-------------------------------------
Reporter: iamadisingh | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: trunk
Severity: normal | Keywords: needs-patch 2nd-opinion
Focuses: |
--------------------------+-------------------------------------
Block hooks are not being applied to templates registered by plugins using
the Template Registration API (`register_block_template()`). This creates
inconsistent behavior where block hooks work for theme templates and user-
created templates, but not for plugin-registered templates.
Originally issue reported in GB:
https://github.com/WordPress/gutenberg/issues/71139
== Step-by-step reproduction instructions
1. Create a plugin.
2. Add this snippet to register a template and hook a block:
{{{#!php
<?php
register_block_template(
'my-plugin//plugin-template',
array(
'title' => 'Test Template',
'description' => 'This is a test template',
'content' => '<!-- wp:separator {"className":"is-style-dots"}
--><hr class="wp-block-separator has-alpha-channel-opacity is-style-
dots"/><!-- /wp:separator -->',
)
);
add_action(
'single_template_hierarchy',
function () {
return array( 'plugin-template' );
}
);
add_filter(
'hooked_block_types',
function ( $hooked_block_types, $relative_position,
$anchor_block_type, $context ) {
if ( 'after' === $relative_position && 'core/separator' ===
$anchor_block_type ) {
$hooked_block_types[] = 'core/post-title';
}
return $hooked_block_types;
},
10,
4
);
}}}
3. Create a new page and add a Separator block
4. Visit a page (using theme template) and a post (using plugin template)
5. Notice the page correctly applies the block hook, while the post
doesn't
**Expected Result:** Block hooks should be applied consistently to all
template sources (theme, user-created, and plugin-registered).
**Actual Result:** Plugin-registered templates do not have block hooks
applied, while theme templates and user-created templates do.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63808>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list