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

Add documentation for "Page creation Block Patterns" #40

Closed
fabiankaegy opened this issue Apr 27, 2022 · 3 comments · Fixed by #92
Closed

Add documentation for "Page creation Block Patterns" #40

fabiankaegy opened this issue Apr 27, 2022 · 3 comments · Fixed by #92

Comments

@fabiankaegy
Copy link
Member

In WordPress 6.0 we've gained the ability to define block patterns as "post-content" patterns. If more than 2 of them are registered the user will be presented with a Modal that allows them to choose from all the post content patterns so that they don't have to choose from a blank slate.

This feature right now does not jet support custom post types in any way but is already very useful for Pages.

@fabiankaegy fabiankaegy added this to the WordPress 6.0 milestone Apr 27, 2022
@fabiankaegy
Copy link
Member Author

Supported fields

  • Title (required) (implicitly translatable)
  • Slug (required)
  • Description (implicitly translatable)
  • Viewport Width
  • Categories (comma-separated values)
  • Keywords (comma-separated values)
  • Block Types (comma-separated values)
  • Inserter (yes/no)

@fabiankaegy
Copy link
Member Author

The DEV Note for the pattern registration via the /patterns directory can be found here: https://make.wordpress.org/core/2022/05/02/new-features-for-working-with-patterns-and-themes-in-wordpress-6-0/

@fabiankaegy
Copy link
Member Author

The Dev note for this feature was just published: https://make.wordpress.org/core/2022/10/10/miscellaneous-editor-changes-for-wordpress-6-1/

Start content patterns for all post types

With WordPress 6.0, developers were able to add patterns that appear in a modal each time a new page was created, thus allowing the user to start from a set of pre-made patterns instead of a blank state. In WordPress 6.1, this feature is expanded to all the post types.
To use this feature, one should include core/post-content in the blockTypes array (same as what happened for pages) and include the desired postTypes where the modal should appear in a newly introduced postTypes property. If postTypes are specified, the pattern is only available on the post types that were set.

Example:

register_block_pattern(
   'custom-pattern',
   array(
       'title'       => _x( 'Start post pattern', 'Block pattern title', 'gutenberg' >),
       'blockTypes'  => array( 'core/paragraph', 'core/post-content' ),
       'postTypes'   => array( 'product' >),
       'content'     => '<!-- wp:paragraph --><p>A start post pattern</p><!-- /wp:paragraph -->',
   )
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant