-
Notifications
You must be signed in to change notification settings - Fork 57
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
Theme created using plugin doesn't render template parts #396
Comments
@madhusudhand this is also the case when changing global styles:
in /create-block-theme/admin/create-theme/theme-templates.php There is a line in a function
Personally, I would like to see this removed so the templates respect the theme as its being designed. |
:/ My comment was actually the 'theme' attribute being undesirable and should be removed. :P I wasn't very clear about that eh? I'm not sure why having the theme attribute NOT set would cause the parts to no longer render. That isn't the case for my observations... Only when it IS present (and doesn't match the folder structure the theme is in) do I see any problems with the templates being rendered. |
Hi! I think we should not remove the theme slug. It's the only way to make it work in some cases as the ones described here, at least some time ago when I tried that.I think we need to be sure we are always the right theme slug. |
Yeah, I realised that after the fact, I think you're right it should be removed if the theme is being exported but not when it's being saved with 'Save Changes', that's why I've added conditional logic on my proposed commit 👍 |
I struggle to see the difference as to why it would be appropriate in one situation but not another. Ultimately the theme imported from being exported is the same as the theme being saved. If it's right to remove the attribute in exported theme what makes it wrong for the "currently loaded" theme? @matiasbenedetto the cases you mention above only seem to matter for PATTERNS not TEMPLATES, which (from what I have observed) work as expected if there is no "theme" attribute (though might NOT work as expected if the "theme" attribute is present and doesn't match the folder structure the theme is in). |
@pbking now I'm confused. I managed to replicate @matiasbenedetto's issue because the difference was when I had created a new template, let's say a "Front Page," and built out the template parts (e.g., 'header', 'footer') by adding some other stuff, etc., in the theme and saved it. The front-page.html was generating the markup that references the current theme:
After making further edits to the template parts, upon saving and removing the "theme" reference as it currently does in the plugin, it was then breaking when rendering as the header and footer. Now that I've revisited it, I can't seem to replicate the issue any longer. I'm not sure what the steps were to break it, but it's not breaking now. It might be related to editing Global styles in the backend and then making further edits in the 'theme.json' file, resulting in a mismatch. Or it could be something else entirely, but it was breaking for me. 🤷♂️ I'll try to keep an eye on this to see if I can identify an emerging pattern. |
Happened to me today too in 6.3 RC 1, header and footer template parts were just left out. It also got rid of the sliders and replaced those with custom setting with the classic input fields. |
I am facing the same issue in 6.2.2. Header, footer and lot of template parts are missing in the child theme. Do you found a workaround? |
I'm experiencing a similar issue: The theme name attribute is being omitted from the template-part code during export, which causes the template-parts to break ("Template part has been deleted or is unavailable"). When I manually add the theme name attribute back to the newly exported theme, the template-parts show up. The manual fix wouldn't be a big deal on one site, but when updating the theme on several sites, it gets pretty tedious. Hopefully this gets solved. |
When this is properly addressed then it will no longer be a problem. The 'theme' attribute is removed on purpose as it's very much an 'environment specific' value. If your theme is installed in a folder, for instance ( It has been partially addressed but there are still scenarios that need more work. Currently only fixed if using the Gutenberg plugin. |
Now that WordPress/gutenberg#54595 has been merged, can we close this issue? |
Yes, now that this GB PR is in Core, I think we can close this 👍 |
In few themes it is observed that the template parts are having a
theme
attribute set. This causes the template part to no render in the site frontend and editor.<!-- wp:template-part {"slug":"secondary-header","theme":"jaida"} /-->
Error in the editor:
Template part doesn't render in the frontend:
Tested by creating a blank theme and exported. It doesn't create any such attribute.
Need to understand the theme creation process from the designers to check if this is still an issue.
The text was updated successfully, but these errors were encountered: