-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
[Feature] Templates APIRelated to API powering block template functionality in the Site EditorRelated to API powering block template functionality in the Site Editor[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
I've noticed that registering a block template with a slug matching exactly page even if not applied (so the meta _wp_page_template does not exist) will be applied if and only if I click on the Template within the editor.
The template is applied only to the Editor.
Below is the code I've used
namespace Plugin\Templates;
function load_template(string $templateName): string {
ob_start();
include plugin_dir_path(__FILE__) . '/templates/' . $templateName . '.php';
return ob_get_clean();
}
add_action( 'init', static function() {
wp_register_block_template(
'templates//page',
[
'title' => 'My Single Page',
'description' => 'This is my single template',
'content' => load_template('page'),
'post_types' => [ 'page' ],
]
);
} );Step-by-step reproduction instructions
- Register a new block template using a slug including '//page' as part of the template name
- Open the Sample Page Edit page
- On Page Panel, click Pages near the right of the Template label
Screenshots, screen recording, code snippet
Screencast.from.2024-09-23.23-41-27.webm
Environment info
WordPress Version: 6.7-alpha-59076
Gutenberg Version: 19.3.0-rc.1
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 EditorRelated to API powering block template functionality in the Site Editor[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended