-
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
Can not insert/use Template Part block within Post Template block #57054
Comments
Also, you can see in the video that there already is a "Post Meta" Template Part block within a Stack within Post Template block. This is part of Twenty Twenty Four template code. Like I've mentioned, adding Template Part block with code works. I've also tried to move the "Post Meta" Template Part block but once I tried to drag it onto a different place I could not reinsert it anywhere within Post Template block. |
Is there any code solution I can use to fix the issue in my theme? |
I tried to find the reason for this and couldn't quite pinpoint the answer looking through PRs but I wonder if it has to do with recursion prevention of some sort. @ntsekouras might you know? |
It seems this is a conscious decision that was taken a long time ago though and could be revisited. I'll also cc @talldan because I think there is some work unifying template parts with patterns, so it seems relevant. |
Thanks for the info. It would be really great if this was reconsidered as it causes confusion with users. Especially when theme adds these with code and user can't modify them visually in Site Editor. |
Maybe the A pattern would probably work fine for this use case as well if it's a user created template part. For post content, I think that would probably be more challenging. Template parts like headers and footers might result in a semantically incorrect web page too easily. The permission models for editing template parts are also quite different, though I haven't looked too deeply into the implications of this. Ideally users wouldn't be able to edit them if they don't have permissions (the same issue has existed with patterns/reusable blocks for a while - #32353, but solutions are now being explored). So I think it would be too soon for adding template parts to post content. |
Agreed, there are potential issues regarding allowing Template Part within Post Content. Personally I haven't stumbled across the need for using Template Part in Post Content. I'm only asking about allowing Template Part within Post Template as that's pretty common use in my themes and currently in Twenty Twenty Four too. |
I have a use case: I need to insert a sidebar into the Content and not give the user control over it. It has certain blocks but will and have different blocks in the future, and I cannot add it to the template because I have blocks above and below that the user should edit. I was considering using grid, but the content is wrapped. I assume I can add .entry-content {display: contents;} and still try to use grid, but the whole thing looks like a hack, and I spent already some time trying to find a way around. Block hooks are also not helping in this matter because they are only working in the template and template parts that I cannot insert in the first place. |
Description
In Site Editor it seems I can not insert a Template Part block into a Post Template block.
When I switch to code editor view and add the Template Part block code as a child of Post Template block, it works.
But in visual view I can not insert or drag the Template Part block into the Post Template block.
Step-by-step reproduction instructions
(Check our the attached video.)
Screenshots, screen recording, code snippet
template-part--post-template.mp4
The video shows Twenty Twenty Four theme, editing "Index" template in Site Editor and trying to add a Template Part block into Post Template block.
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: