You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Template Editing: Templates do not recognize theme template parts without a theme attribute #36124
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.
Open a post or page in the editor, and select "New" under the Template panel:
Note that if your theme uses a theme slug to point to its template part, the template part will appear. Otherwise it will show a "Template not found" error.
@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 _gutenberg_inject_theme_attribute_in_content was renamed to _inject_theme_attribute_in_block_template_content in case you want to test it out.
what do you think about that workaround above?
I don't like the idea of adding this to the theme, since the utility function comes from this file which states:
Temporary compatibility shims for features present in Gutenberg.
This file should be removed when WordPress 5.9.0 becomes the lowest
supported version by this plugin.
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'm removing this issue from WP 5.9 project board since RC1 was released last night.
We can add the defaultTemplate option to the theme.json and handle theme attribute injection internally. Probably task for the next major release since we have a workaround.
Closing as fixed: render_block_core_template_part() now falls back to the active theme when the attribute is absent ($theme = $attributes['theme'] ?? get_stylesheet();), so theme template parts resolve without an explicit theme attribute. Please open a new issue if a resolution gap remains in current template editing.
Activity
Mamaduka commentedon Nov 2, 2021
Here's a workaround for now:
kjellr commentedon Nov 12, 2021
@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.
jffng commentedon Nov 12, 2021
It works, though it looks like
_gutenberg_inject_theme_attribute_in_contentwas renamed to_inject_theme_attribute_in_block_template_contentin case you want to test it out.I don't like the idea of adding this to the theme, since the utility function comes from this file which states:
Mamaduka commentedon Nov 12, 2021
You should use
_inject_theme_attribute_in_block_template_contentin theme. But I agree it’s private utility and third parties shouldn’t depend on it.kjellr commentedon Nov 12, 2021
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.
noisysocks commentedon Nov 23, 2021
I'll add it to the board as a general bug to fix (not a blocker).
Mamaduka commentedon Jan 5, 2022
I'm removing this issue from WP 5.9 project board since RC1 was released last night.
We can add the
defaultTemplateoption to the theme.json and handle theme attribute injection internally. Probably task for the next major release since we have a workaround.youknowriad commentedon Jul 22, 2026
Closing as fixed: render_block_core_template_part() now falls back to the active theme when the attribute is absent ($theme = $attributes['theme'] ?? get_stylesheet();), so theme template parts resolve without an explicit theme attribute. Please open a new issue if a resolution gap remains in current template editing.