Skip to content

Missing content when replacing a template part (such as a header) with a pattern (such as a header pattern) that also includes a pattern bundled from the repository #50532

@James-Roberts

Description

@James-Roberts

Description

If a theme bundles a pattern in the theme.json file via the repository (https://wordpress.org/patterns/) and then includes that pattern in a header pattern (bundled in the /patterns/ directory), the pattern from the repo is NOT added to the front end of the site when the template part is Replaced from within the Site Editor. It IS, however, seen in the editor (just not the front end).

Tested both with and without the Gutenberg plugin installed.

Expected Behaviour

I would expect that when we replace a header template part with a header pattern, then for the new template part to include all content on the front end, even if that header pattern includes one or more patterns from the WordPress repository https://wordpress.org/patterns/ (added to the theme via theme.json).

Actual Behaviour

When we replace a header template part with a header pattern that includes a pattern from the WordPress repository, the content is added to the editor, but the content generated by the pattern from the WordPress repository is missing from the front end of the website (but visible in the editor).

Step-by-step reproduction instructions

Steps to reproduce, using Twenty Twenty-Three as an example:

  1. Edit the theme.json file to include a pattern from the repository. For example, contact-and-social-links.
  2. Create a header.php file within the /patterns/ directory. Create a new header pattern (make sure to add Block Types: core/template-part/header). You can just copy the content from the header.html template part.
  3. Somewhere within the header.php pattern, include the pattern from the repository. <!-- wp:pattern {"slug":"contact-and-social-links"} /--> as an example.
  4. In the WordPress admin, click Appearance -> Editor. Click in the Site Editor preview window, to begin editing the index template.
  5. In the editor, click on the header template part, and click the more options link in the toolbar (three dots). Click Replace Header.
  6. Select the new header pattern - You should see a preview, which includes the pattern from the repo.
  7. The header is successfully replaced by the new template part, which is inserted into the editor, which DOES include the pattern we included from the repo.
  8. Save changes.
  9. Now if you visit the home page, you will see that the pattern from the repository is missing within the new header. If you go back into the editor, you can see the pattern is there, it is just not being added to the front end for some reason.
  10. The only way to get the pattern to show up on the front end, is to go into the template part that was automatically created when replacing the old header, make a change, and then save the template part.

Screenshots, screen recording, code snippet

Adding the pattern from the repo to Twenty Twenty-Three, and creating the new header pattern:
theme_setup

In the above gif, you can see me bundle https://wordpress.org/patterns/pattern/contact-and-social-links/ with Twenty Twenty-Three. I then create a new header pattern and include the pattern I bundled from the repo

header.php from the above .gif https://pastebin.com/fuekwb0g.
theme.json from the above .gif https://pastebin.com/Y2QSwW7N.

After theme modifications, steps to reproduce:
steps_to_reproduce

After the header template part has been replaced with the new header pattern, we can see that the new header DOES include the content from https://wordpress.org/patterns/pattern/contact-and-social-links/. However, when we visit the front end of the website, this specific content is missing. I then go and modify the template part that was automatically created and save changes, which seems to be the only way to make the additional content added by the pattern from the repo appear on the front end.

Environment info

  • WordPress 6.3-alpha.
  • Gutenberg 15.7.1.
  • Theme: Twenty Twenty-Three, modified to include a custom header pattern and a pattern from the repo.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Pattern DirectoryThe Pattern Directory, a place to find patterns[Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced[Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions