title (required): A human-readable title for the pattern.
content (required): Raw HTML content for the pattern.
description: A visually hidden text used to describe the pattern in the inserter. A description is optional but it is strongly encouraged when the title does not fully describe what the pattern does.
categories: A list of pattern categories used to group block patterns. Block patterns can be shown on multiple categories.
keywords: Aliases or keywords that help users discover it while searching.
viewportWidth: Specify the width of the pattern in the inserter.
As an addition to the category, I would like to give an example for those who did not know what syntax to use. Since a block pattern can be assigned to multiple categories you can use an array to place it in the right category. example:
Just a heads up for block theme developers: since WordPress 6.0 you can also register patterns in a block theme simply by placing PHP files with patterns in your theme’s /patterns subfolder.
Good call! Registering the block pattern straight from functions.php results in the editor crashing with an obscure JS error after opening the patterns pannel, without any PHP errors or warnings being triggered. Calling register_block_pattern inside the init hook solves this perfectly! Thanks!
Per the Block Patterns documentation in the Block Editor Handbook, the $pattern_properties array includes:
and the example function given is:
how to define/register a category can be found here: https://developer.wordpress.org/reference/functions/register_block_pattern_category/
Just a heads up for block theme developers: since WordPress 6.0 you can also register patterns in a block theme simply by placing PHP files with patterns in your theme’s
/patternssubfolder.The docs & handbook don’t seem to mention it, but I gather
register_block_pattern()should be called from a handler attached to theinithook.register_block_patterninside the init hook solves this perfectly! Thanks!If the core block patterns are removed via:
Make sure that there is at least one block pattern category registered. The block editor crashes if none are present.
A basic example of how to register a new pattern block.