Ask any question about WordPress here... and get an instant response.
Post this Question & Answer:
How can I create a custom block pattern in the WordPress block editor?
Asked on Mar 19, 2026
Answer
Creating a custom block pattern in the WordPress block editor allows you to define reusable layouts for your content. This can be done by registering a block pattern using a simple function in your theme's `functions.php` file.
<!-- BEGIN COPY / PASTE -->
function my_custom_block_pattern() {
register_block_pattern(
'my-theme/my-custom-pattern',
array(
'title' => __('My Custom Pattern', 'text-domain'),
'description' => _x('A custom block pattern for my theme.', 'Block pattern description', 'text-domain'),
'content' => "<!-- wp:paragraph --><p>" . __('Your custom content here.', 'text-domain') . "</p><!-- /wp:paragraph -->",
)
);
}
add_action('init', 'my_custom_block_pattern');
<!-- END COPY / PASTE -->Additional Comment:
- Ensure you replace "my-theme/my-custom-pattern" with a unique name for your pattern.
- Use the `__('Text', 'text-domain')` function to ensure your text is translatable.
- Block patterns can be accessed in the block editor under the "Patterns" tab.
- Test your pattern to ensure it appears correctly in the editor.
Recommended Links:
