What are Block Patterns?
Patterns provide:- Reusable layouts: Pre-configured combinations of blocks
- Quick starting points: Jump-start content creation with templates
- Design consistency: Ensure layouts match your design system
- User productivity: Speed up common content creation tasks
Registering Block Patterns
PHP Registration
Useregister_block_pattern() to register a pattern:
Call
register_block_pattern() from a handler attached to the init hook.Pattern Properties
Required Properties
title (required)
Human-readable title displayed in the pattern inserter.content (required)
Block HTML markup for the pattern. This is the serialized block format.Optional Properties
description
A visually hidden text used to describe the pattern in the inserter. Helps users discover patterns while searching.categories
Array of registered pattern categories to group the pattern.keywords
Array of aliases or keywords that help users discover the pattern while searching.viewportWidth
Intended width of the pattern for a scaled preview in the inserter.blockTypes
Array of block types the pattern is intended for. Makes the pattern available in block transforms.postTypes
Restrict the pattern to specific post types.templateTypes
Array of template types where the pattern is relevant.inserter
Control visibility in the inserter. Set tofalse to hide the pattern (for programmatic use only).
source
Denotes the source of the pattern.Complete Pattern Example
Pattern Categories
Group patterns into categories for better organization.Registering Pattern Categories
The category won’t show in the Patterns panel unless at least one pattern is assigned to it.
Complete Category Example
Unregistering Categories
Unregistering Block Patterns
Remove previously registered patterns:Call
unregister_block_pattern() from a handler attached to the init hook.Contextual Block Patterns
Patterns can be attached to specific block types, making them available as transforms.Multi-Block Patterns
Patterns can transform multiple selected blocks:Semantic Block Patterns
In block themes, mark patterns as “header” or “footer” (template part areas):Common Pattern Examples
Hero Section
Testimonial
Pricing Table
Creating Pattern Content
To generate the block HTML markup for patterns:Method 1: Copy from the Editor
1
Create the layout in the editor
Build your pattern layout using the block editor.
2
Copy to clipboard
Select all blocks (Cmd/Ctrl + A) and copy them.
3
View as HTML
Click the three dots menu → “Copy all blocks” or use Code Editor view to see the HTML.
4
Paste into your pattern
Paste the HTML markup into the
content field.Method 2: Export from the Editor
Use the Pattern export feature (if available in your WordPress version) to export patterns created in the editor.Best Practices
- Provide clear titles and descriptions: Help users understand when to use each pattern
- Use appropriate categories: Make patterns easy to discover
- Add keywords: Include search terms users might use
- Set viewport width: Ensure patterns display correctly in preview
- Use placeholder content: Make it obvious what content should be replaced
- Test across themes: Ensure patterns work with different themes
- Consider accessibility: Use semantic HTML and proper heading hierarchy
- Keep patterns focused: Each pattern should serve a specific purpose
Pattern vs Reusable Block
Use patterns for layout templates.
Use reusable blocks for repeated actual content.
Related Documentation
- Block Variations - Different configurations of a single block
- Block Templates - Default block layouts for post types
- Block Transforms - Convert between block types