-
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
Templates: Retain custom templates when switching themes #31954
Templates: Retain custom templates when switching themes #31954
Comments
Thanks for opening the issue Anne. I have been trying to find a solution to this for many months, but the incorrect assumption was made that this is a low priority due to it being the enhancement of a "new" feature. This is not actually true. The block-based nature may be new, but the ability for users to customise parts of their theme is nothing new. It has long been available through widget areas and menus, albeit not in a block-based way. Widget areas and menus already have a mechanism whereby users can retrieve their customisations (i.e. widget areas and menus) from deactivated themes and apply them to a new theme. I explained this at #31397. Given that they can already do this with widget areas and menus, users should expect nothing less than to be able to do it with block-based templates and template parts as well. However, the current implementation of templates and template parts is incredibly poorly designed and makes it near impossible for the new theming system to mirror what the old one is quite easily capable of. Please see my new patch at #31971 that implements a cleaner approach based on theme mods, to mirror the same approach that widget areas and menus have successfully been using for years. The patch, plus a simple addition to the UI, can easily solve this issue. |
User preferences when switching block themes are likely to be highly subjective. Some folks will expect all customisations to be retained, others will want a totally fresh start. Some will probably want granular per-customisation control. I opened #25071 last year to discuss the switching UX, but didn't get any responses yet 😭
Maybe it's always been this way, but I see that custom templates do remain in Appearance > Templates after a theme switch, but they do not resolve on the frontend 🤔 I suppose this is related to the slug and is what @carlomanf's PR would address. |
That's disappointing, especially because I believe the behaviour has changed since you opened it. At the time, user templates did persist after a theme switch, but now they don't. I agree with you that neither of these blanket solutions are ideal, and it would be better to give the user some kind of discretion. Still, the lack of responses is somewhat understandable, because the underlying infrastructures both then and now are built in such an inflexible way that they make it near impossible to create such an experience anyway. That is what my patch changes. Rather than locking everyone in to one particular behaviour, it would provide the underlying foundation to be able to implement the kind of theme switching experience that #25071 talks about. |
I wanted to document some thoughts from @youknowriad in slack for posterity around 5.8:
|
I'm also of the opinion that custom block templates should be retained. If a template is the standard theme's default template, then sure — it should change to whatever the theme decides. But otherwise, if I've created and set a specific template for a specific page, then that should be retained. I get that the UX may be a bit more daunting, but having templates that you've created with theme User flow:I create a blank.html template that only renders the post content block (just like BlockBase). I've assigned it to display on a particular page, as I want no headers or footers — just my block content for this landing page. I change my theme to get a new look cause I feel like it, but now my landing page has a header, footer and an empty sidebar next to it. To resolve this today, I need to create a blank custom template and assign it to the page once again. If I ever change my theme, I end up with the same issue, needed to create the blank template again (while deleting the old one). Next steps:While we can't assume that every time I change a theme, all my custom templates should stay, I do lean in the direction that that behavior should be the default experience. Maybe we have a mechanism that let's me opt to resetting all templates as the theme's default templates, instead of what happens today where everything resets when a theme is changed. In addition, I should also be able to use any template I've created on any theme. I'm not sure what the purpose behind locking templates to themes is, but its seems counter-intuitive. Related to #25071. |
Just wanted to follow up to note that there was consensus from the folks who participated in the block theme switching exploration around wanting to be able to keep custom templates while switching themes. You can read more specific feedback here but this continues to be advocated for: https://make.wordpress.org/test/2021/10/05/fse-program-block-theme-switching-summary/ |
I opened another patch to aid with a solution to this, if anyone would like to test: WordPress/wordpress-develop#2179 |
What problem does this address?
This is part of feedback from WP Tavern's coverage of the sixth call for testing with the FSE Outreach program:
Currently, if you create custom block templates and switch to another theme (even if it's block based), these custom templates are lost.
What is your proposed solution?
The approach can likely happen in a few ways or in combination:
a) make it clearer when creating templates that they are theme dependent
b) offer a way for people to migrate their templates to new themes (no clue on technical feasibility)
c) make it clear when switching themes what will be lost
The text was updated successfully, but these errors were encountered: