-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Header template-part disappears from template after theme change #42181
Comments
I have tested this, but I'm unable to replicate the issue. The new theme correctly loads its own |
@sunyatasattva Are you able to replicate this? I'd appreciate it if you could have a look. 🙏 |
Hey @danieldudzic and @kmanijak, I think I see what's the problem here. It seems like when you activate a theme you have a template part that belongs to that theme. If you then modify a template containing that template part, and then switch theme, the problem appears: probably because the theme doesn't want to override any user changes. This is probably a bug in core, to be honest. |
I don't think this is a bug. As you mentioned, a theme-related template part belongs to that theme. If the new theme provides its own template part, it should take priority over the customized one (from the previous theme). |
Mm, I think we are talking about two different things right now, perhaps I didn't express myself correctly. You say:
That's exactly what is not happening. The new theme template part won't take priority over a customized one. Also, I'm not sure I agree that it should, and this is a much more nuanced conversation than what's happening here, albeit very similar: what happens here is that if someone customized a template which includes a template part, and then changes a theme, that template part won't be updated, causing an error, as it's not available anymore. This is why I think this is a bug. I hope I expressed myself correctly here. |
I see what you are saying. Thank you for clarifying the situation for me. I was now able to replicate the issue. I have tried replicating this with WooCommerce disabled but wasn't able to. I was able to replicate it with 6.3.2 and TT3. Do you have any idea where the bug could be originating from? |
Thanks for adding more info! I added the Header customization as a necessary step in steps to reproduce.
@danieldudzic, in such a case my guess would be |
For me, in order to reproduce, I had to:
Not sure if it's only me, but without step 5 I couldn't reproduce. 😓 I also noticed a couple of things:
IMO the best solution would be to do the same with WooCommerce templates: so when modifying a WooCommerce template, it's saved "attached" to the theme and, when switching themes, the default template is loaded again. Switching back to the initial theme, should load the modified template. Does that sound like a good approach? cc @gigitux @tjcafferkey as this seems related to the project to refactor of BlockTemplatesController. |
@Aljullu Yes, this issue will be addressed with the project about BlockTemplatesController. @nielslange opened a similar issue woocommerce/woocommerce-blocks#11106. I want to highlight that this is not a regression introduced by us in the last weeks or for some changes in WordPress 6.4. I think that we have had this wrong behavior for a long time, so even if we must fix it, should we keep the label |
I'm comfortable with removing the |
It makes sense! The issue has been added to #42251! Thanks, @tjcafferkey! |
Description
The header template part disappears on the frontend after updating the theme, when used in other templates.
Steps to reproduce
/shop
)Expected: Header is still there
Actual: Header is missing
More details
When entering the code editor you can see the template part has a theme assigned:
<!-- wp:template-part {"slug":"header","theme":"twentytwentythree"} /-->
After updating the theme value manually in the code editor to
twentytwentyfour
it appears on the frontendThe text was updated successfully, but these errors were encountered: