Skip to content
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

Template Parts not displaying when inside patterns #55202

Closed
scruffian opened this issue Oct 10, 2023 · 5 comments
Closed

Template Parts not displaying when inside patterns #55202

scruffian opened this issue Oct 10, 2023 · 5 comments
Labels
[Block] Template Part Affects the Template Parts Block [Type] Bug An existing feature does not function as intended

Comments

@scruffian
Copy link
Contributor

What problem does this address?

When a template part is inside a pattern block, it appears missing on the frontend. To reproduce:

  1. Update to the latest version of WordPress trunk
  2. Switch to the TT4 theme
  3. Open the site in the frontend and you'll see this error:
    Template part has been deleted or is unavailable: header

What is your proposed solution?

This seems to have been introduced in #54651

The problem seems to be that although the template parts are given theme slugs when they are processed by traverse_and_serialize_blocks, when the block code itself comes to process the block the theme slug is missing. I can't work out why.

cc @gziolo as you worked on #54651 :)

@gziolo
Copy link
Member

gziolo commented Oct 10, 2023

@ockham, it is very likely that we missed adding the replacement for _inject_theme_attribute_in_block_template_content for patterns as they can also contain template parts.

The way to validate that would be to replace the following code:

https://github.com/WordPress/wordpress-develop/blob/33d124299255e7f7faa3f2dbb5f1c6bb43f9b0f4/src/wp-includes/class-wp-block-patterns-registry.php#L167-L172

to look more like:

https://github.com/WordPress/wordpress-develop/blob/33d124299255e7f7faa3f2dbb5f1c6bb43f9b0f4/src/wp-includes/block-template-utils.php#L552-L560

@scruffian
Copy link
Contributor Author

It works! WordPress/wordpress-develop#5450

@mikachan mikachan moved this to In Progress in WordPress 6.4 Editor Tasks Oct 10, 2023
@t-hamano
Copy link
Contributor

It looks like an error similar to this issue has been reported. However, these issues were reported a long time ago and may not be directly related...

@gziolo
Copy link
Member

gziolo commented Oct 10, 2023

@t-hamano, thank you for posting references to other tickets. It would be great to test them with all the latest changes as it seems that they could get resolved, too.

@richtabor richtabor changed the title Template Parts not displaying when inside patterns. Template Parts not displaying when inside patterns Oct 10, 2023
@jordesign jordesign added the [Block] Template Part Affects the Template Parts Block label Oct 11, 2023
@mikachan
Copy link
Member

I believe this has been fixed with WordPress/wordpress-develop#5450, so we can probably close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants