-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template Editing: Templates do not recognize theme template parts without a theme attribute #36124
Comments
Here's a workaround for now: /**
* Add a default block template.
*/
function twentytwentytwo_default_block_template( $settings ) {
$template_content = file_get_contents( get_theme_file_path( 'block-templates/single.html' ) );
$settings['defaultBlockTemplate'] = _gutenberg_inject_theme_attribute_in_content( $template_content );
return $settings;
}
add_filter( 'block_editor_settings_all', 'twentytwentytwo_default_block_template' ); |
@jffng / @carolinan what do you think about that workaround above? If that is generally ok then we can use it for Twenty Twenty-Two. Otherwise I think we need to have this issue prioritized for 5.9. |
It works, though it looks like
I don't like the idea of adding this to the theme, since the utility function comes from this file which states:
|
You should use |
Ok, thanks for weighing in. @noisysocks — what do you think about prioritizing this for 5.9? It's preventing block themes from using theme-supplied template parts in the template editor. |
I'll add it to the board as a general bug to fix (not a blocker). |
I'm removing this issue from WP 5.9 project board since RC1 was released last night. We can add the |
A
theme
attribute is not required for template parts to render in the site editor, however it is required in the template editor.The fallback hierarchy here should be the same, so that the Template editor knows to look for templates in the theme when there's no
theme
slug provided.To reproduce:
The following uses Twenty Twenty-Two as an example, but this should be the case with any block theme that uses a template part in its templates.
Screenshots:
theme
attributetheme
attributeThe text was updated successfully, but these errors were encountered: