What are Block Patterns?
Patterns combine multiple blocks into reusable layouts. Once inserted, the blocks become regular editable blocks that users can modify.Unlike reusable blocks, patterns are not linked to their original definition. Changes to a pattern don’t affect previously inserted instances.
Registering Patterns (PHP)
Register patterns using theregister_block_pattern function:
register_block_pattern
string
required
Machine-readable name with format
namespace/pattern-namearray
required
Array of pattern properties
Pattern Properties
string
required
Human-readable title displayed in the inserter
string
required
Block HTML markup for the pattern
string
Visually hidden text describing the pattern (helpful for search)
array
Array of registered pattern category slugs
array
Search keywords to help users discover the pattern
integer
Intended width for scaled preview in the inserter
array
Block types this pattern is intended for (enables pattern transforms)
array
Post types where this pattern is available
array
Template types where the pattern makes sense (e.g.,
404, single-post)boolean
default:"true"
Whether to show in the inserter (set to false for programmatic use only)
string
Source of the pattern:
plugin or themeBasic Pattern Example
Pattern with Multiple Blocks
Pattern Categories
Register custom pattern categories:register_block_pattern_category
string
required
Machine-readable category identifier
array
required
Array with category properties
The category will only appear in the patterns tab if at least one pattern is assigned to it.
Core Pattern Categories
featuredtextgallerycall-to-actionbannerheaderfooterpostsbuttons
Contextual Patterns (Pattern Transforms)
Attach patterns to specific block types to enable pattern transformations:- Appear in the paragraph block’s transform menu
- Keep the paragraph’s existing content
- Apply the pattern’s styling attributes
Multi-Block Patterns
Patterns can target multiple block types:Semantic Block Patterns
For block themes, mark patterns as template part areas:Restricting Patterns by Post Type
Restricting by Template Type
Hidden Patterns (Programmatic Use)
Unregistering Patterns
unregister_block_pattern
Unregister Pattern Categories
Pattern Examples from Core
Two Columns Pattern
Call to Action Pattern
Tips for Creating Patterns
Use real content in examples
Use real content in examples
Provide meaningful placeholder content that demonstrates the pattern’s purpose.
Set appropriate viewport width
Set appropriate viewport width
Use
viewportWidth to ensure patterns preview correctly in the inserter.Include helpful descriptions
Include helpful descriptions
Write clear descriptions to help users understand when to use each pattern.
Use semantic categories
Use semantic categories
Assign patterns to appropriate categories to improve discoverability.
Add relevant keywords
Add relevant keywords
Include search terms that users might type when looking for the pattern.
Test pattern transforms
Test pattern transforms
If using blockTypes, ensure transforms work correctly with user content.
Best Practices
- Register on init hook: Always register patterns during the
initaction - Escape content: Use
esc_html__()for translatable text - Use consistent naming: Follow
namespace/pattern-nameconvention - Provide translations: Wrap all user-facing strings in translation functions
- Consider accessibility: Ensure patterns use semantic HTML and proper heading hierarchy
Next Steps
Inner Blocks
Build blocks that contain other blocks
Block API Overview
Return to Block API fundamentals