-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add support for replacing "general" template parts #44689
Comments
Thanks for reporting this. It seems like there was a decision made in #40787 to only make 'Replace' work for Header or Footer areas. The button was also moved from the toolbar to the options menu. I guess this triggers a discussion about the change in #40787. I see the purpose of removing the 'Replace' button for 'General' template parts, but themes can register additional semantic areas to Header and Footer, so perhaps 'Replace' should still be available for those. Otherwise, I wonder what the purpose of allowing themes to add areas is. |
Thanks for the infomation!
I see. I understand. Users can easily change the layout by replacing template parts. I believe that is probably why the header and footer replacements were left in place. However, the content area between the header and footer can no longer be easily changed in layout. Posts and pages can be easily changed with custom templates, but archive pages, search results, and 404 pages cannot. I used to take advantage of the template parts replacement feature in my theme to easily replace layouts in all types of templates, but since 6.1 all of these no longer work. https://github.com/inc2734/unitone If possible, I would like to see template parts other than General be replaceable. |
I see this note in the original PR. We introduced to search for this modal in #42459. I think James is AFK this week, but removing or altering restrictions shouldn't be a problem. |
@jameskoster, only template parts assigned to Header or Footer area are currently replaceable - #40787. |
I was responding to this comment:
It seems like @inc2734 thought that headers/footers weren't replaceable now? |
I do know that the header and footer are interchangeable! I have made an issue about replacing template parts related to areas that I have added my own in |
Ah I see. Sorry I was a bit slow on the uptake there :) That use case seems perfectly fair to me. I suppose we should revise the logic. Instead of "only headers and footers can be replaced" it should be "any template part except general can be replaced". |
Plus one. Just noticed the removal of replacement for general template parts and would plus one offering a replacement menu item for them as well. There's a lot of cool utility in being able to swap template parts in and out. My initial user reaction was to be confused at the difference. |
Hi everybody. Usecase descriptionBuilding my first block theme I use several template parts with various alternative layouts for the same functionality/area. For example a posts list (query) with and without a sidebar. Or alternative posts list entry layouts. I must have tested the template part block replacement on a header or footer, so I happily presumed it works for every template part. And that's why I created multiple template parts for same areas: so users can choose which one they prefer. You can imagine my frustration when I was trying to figure out what I do wrong in the theme as I couldn't replace my "uncategorized" template parts in Site Editor during testing. Finally I found this thread which provided me the answer. Sort of. IssueI don't really understand the reasoning for removing "Replace" button/menu for Template Part block.
Proposed solutionPlease re-enable the "Replace" functionality for Template Part block regardless the template area. Having any restrictions here creates confusion from user experience point of view, I think. Also, it would be great to have a "Replace" toolbar button (always visible for Template Part block) instead of hiding it in the options menu so users can actually immediately see that a Template Part block provides them with a great flexibility of swapping the template parts (unlike it is with patterns). Thanks for re-considering this! |
@jameskoster @Mamaduka Is there any progress on this please? Will we be able to replace template parts in next WP version (6.3)? |
@webmandesign came across this issue and wanted to note it hasn't been completed for 6.3 but that I've added this to the UX & Polish board since it appears to be a straight forward dev task. |
Thank you for the update, @annezazu |
Chiming in to say that I would love to see this functionality, based on this: #52859 |
Currently there are dedicated modals for each replace flow:
This implementation primarily caters to semantic replacement flows, IE replacing 'Header A' with 'Header B'. We can expand on that by offering generic replacement options too, IE replacing 'Header A' with 'General Template Part Z'. This is the sort of flow I was hoping to facilitate via #39308 (comment) (which needs a design revisit). In the short term, the replace flow could trigger a modal that includes all template parts, with the contextual category pre-selected. IE replacing a footer would invoke something like: |
Thanks for chiming in with a possible design. Going to move this to the design section of UX & Polish based on the added label! |
+1 Please consider re-enabling the This Theme designers or plugin developers can add custom areas and create several template parts for that area. Some examples of custom areas that could be implemented:
With the Please also consider moving back the |
Do you still provide a "replace" option only for "header, footer" areas? Are there any updates on this issue? |
To align a bit more here, the "Replace" functionality has iterated as a "Design" panel in the Inspector (related #63497). |
We're getting pretty close to the current "shuffle" functionality within patterns though, where you can swap between patterns in the same category. Areas = pattern categories. |
Description
Define your own template part area. Then, create multiple template parts that belong to that area. Open the site editor and insert one of the template parts you created.
At this point, in WordPress 6.0, you will see "Replace" in the toolbar of that template part, but not in 6.1.
It does not appear even after activating the Gutenberg plugin.
Step-by-step reproduction instructions
Since it is necessary to define the template parts area and create the template parts file, TT2 is used as an example.
1. Add code to functions.php.
2. Create template parts.
Open
/parts
. And create this files./parts/test-1.html
/parts/test-2.html
3. Add code to theme.json.
4. Add template part on the site editor.
In 6.0, "Replace" appears on the toolbar.
Not shown in 6.1.
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: