On this page
register_block_pattern( string $pattern_name, array $pattern_properties ): bool
Registers a new block pattern.
Parameters
$pattern_namestring Required-
Block pattern name including namespace.
$pattern_propertiesarray Required-
List of properties for the block pattern.
See WP_Block_Patterns_Registry::register() for accepted arguments.More Arguments from WP_Block_Patterns_Registry::register( ... $pattern_properties )
List of properties for the block pattern.
titlestringRequired. A human-readable title for the pattern.contentstringRequired. Block HTML markup for the pattern.descriptionstringOptional. Visually hidden text used to describe the pattern in the inserter. A description is optional, but is strongly encouraged when the title does not fully describe what the pattern does. The description will help users discover the pattern while searching.viewportWidthintOptional. The intended width of the pattern to allow for a scaled preview within the pattern inserter.categoriesarrayOptional. A list of registered pattern categories used to group block patterns. Block patterns can be shown on multiple categories.
A category must be registered separately in order to be used here.blockTypesarrayOptional. A list of block names including namespace that could use the block pattern in certain contexts (placeholder, transforms).
The block pattern is available in the block editor inserter regardless of this list of block names.
Certain blocks support further specificity besides the block name (e.g. forcore/template-partyou can specify areas likecore/template-part/headerorcore/template-part/footer).keywordsarrayOptional. A list of aliases or keywords that help users discover the pattern while searching.
Return
bool True if the pattern was registered with success and false otherwise.
Source
File: wp-includes/class-wp-block-patterns-registry.php. View all references
function register_block_pattern( $pattern_name, $pattern_properties ) {
return WP_Block_Patterns_Registry::get_instance()->register( $pattern_name, $pattern_properties );
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Block_Patterns_Registry::get_instance() wp-includes/class-wp-block-patterns-registry.php | Utility method to retrieve the main instance of the class. |
Used By
| Used By | Description |
|---|---|
| _register_remote_theme_patterns() wp-includes/block-patterns.php | Registers patterns from Pattern Directory provided by a theme’s |
| _register_theme_block_patterns() wp-includes/block-patterns.php | Register any patterns that the active theme may provide under its |
| _load_remote_featured_patterns() wp-includes/block-patterns.php | Register |
| _load_remote_block_patterns() wp-includes/block-patterns.php | Register Core’s official patterns from wordpress.org/patterns. |
| _register_core_block_patterns_and_categories() wp-includes/block-patterns.php | Registers the core block patterns and categories. |
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/register_block_pattern