WordPress/gutenberg

Patterns from the pattern directory do not show if placed in a template

Open

#64,104 建立於 2024年7月30日

在 GitHub 查看
 (12 留言) (0 反應) (0 負責人)JavaScript (9,607 star) (3,893 fork)batch import
Good First Issue[Feature] Pattern Directory[Feature] Patterns[Status] In Progress[Type] Bug

描述

Description

I encountered this in a custom theme but I can also reproduce it with Twenty Twenty-Four, with no plugins installed. I only tested on WP 6.6.1.

Twenty Twenty-Four enables these two patterns from the pattern directory in theme.json:

	"patterns": [
		"three-columns-of-services",
		"clients-section"
	],

The theme then uses the clients section pattern inside twentytwentyfour/page-about-business.

When I create a new page and select the "About" business pattern, the remote pattern displays correctly in both the editor and front.

But if I edit a template HTML file and include the clients section or any other pattern from the pattern directory, the pattern only shows in the editor.

Step-by-step reproduction instructions

These example instructions uses Twenty Twenty-Four, but it can be reproduced in other block themes.

  1. Activate Twenty Twenty-Four.
  2. Set reading settings to displaying the latest posts.
  3. Make sure there are no template changes saved that can interfere when you edit the HTML template directly.
  4. You may also want to consider enabling the theme development mode constant WP_DEVELOPMENT_MODE. define( 'WP_DEVELOPMENT_MODE', 'theme' ); For example in wp-config.php.
  5. Open home.html in your code editor. Add the pattern to the template and save: <!-- wp:pattern {"slug":"clients-section"} /-->
  6. Go to Appearance > Editor.
  7. Confirm that the pattern is showing in the Site Editor.
  8. View the homepage on the front of the site. Confirm that the pattern is not showing.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.6.1.

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

貢獻者指南