How to Create and Use Block Patterns in WordPress
Block patterns in WordPress are pre-designed groups of blocks that you can insert into any page or post with a single click. They help you build complex layouts—like pricing tables, testimonials, or call-to-action sections—without starting from scratch. This guide walks you through finding, inserting, and creating your own block patterns, both in the block editor and via code.
What You’ll Need
- A WordPress site (version 5.4 or later for core block patterns, 5.5+ for the pattern directory).
- Administrator or editor access to the site.
- For custom patterns: a code editor (like Notepad++ or VS Code) and FTP or a file manager in your hosting control panel, or a plugin like Code Snippets.
Step-by-Step
Using Existing Block Patterns
- Open the post or page where you want to add a pattern.
- Click the + (block inserter) button at the top left of the editor.
- Switch to the Patterns tab (it looks like a grid icon).
- Browse the categories (Buttons, Columns, Gallery, etc.) or search for a keyword like “pricing� or “testimonial�.
- Click a pattern to preview it; click Add to insert it into your content.
- After insertion, you can edit any text, image, or style within the pattern just like normal blocks.
Creating a Custom Block Pattern (Code Method)
- In your WordPress admin, go to Appearance → Theme File Editor (or use FTP to edit your theme’s
functions.phpfile). - Add the following code at the end of the file, replacing the placeholder content with your own block markup:
function my_theme_register_block_patterns() {
register_block_pattern(
'my-theme/my-custom-pattern',
array(
'title' => 'My Custom Call to Action',
'description' => 'A simple CTA with a heading, text, and button.',
'categories' => array( 'call-to-action' ),
'content' => '<!-- wp:group --><div class="wp-block-group"><!-- wp:heading --><h2>Get Started Today</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Sign up now to unlock exclusive benefits.</p><!-- /wp:paragraph --><!-- wp:buttons --><div class="wp-block-buttons"><!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link" href="#">Sign Up</a></div><!-- /wp:button --></div><!-- /wp:buttons --></div><!-- /wp:group -->',
)
);
}
add_action( 'init', 'my_theme_register_block_patterns' );
- Save the file. Your pattern will now appear in the Patterns tab under the “My Theme� category (or whatever category you specified).
Creating a Pattern via the Editor (Using the “Create Pattern� Feature)
- In the editor, build your layout using blocks (e.g., a heading, an image, a button).
- Select all the blocks you want to include in the pattern.
- Click the three-dot menu (options) in the block toolbar, then choose Create pattern.
- Give your pattern a name, choose a category (or create a new one), and optionally add a description.
- Click Create. The pattern is saved to your site and will appear in the Patterns tab under the chosen category.
Common Mistakes
- Not checking for plugin conflicts: Some caching or security plugins can prevent the pattern editor from saving. Clear your cache after creating a pattern.
- Using unsupported blocks in code: If you manually code a pattern with a block that isn’t registered (e.g., a plugin block that isn’t active), the pattern will appear broken or blank.
- Forgetting to escape HTML in code: When writing patterns in PHP, always use single quotes or escape double quotes properly. A single syntax error can crash your site.
- Overwriting theme files without a backup: Editing functions.php directly can break your site. Always keep a backup or use a child theme.
Tips
- Use the Reusable block feature for content that repeats across many pages, and reserve patterns for larger, more complex layouts that you might tweak each time.
- When creating patterns in code, use the
block_categoriesfilter to add custom categories so your patterns are easy to find. - Check the WordPress Pattern Directory for inspiration and ready-made patterns you can copy and adapt.
- Keep your patterns focused. A pattern with too many blocks can be overwhelming; break it into smaller patterns that can be combined.
Troubleshooting
- Pattern not showing in the inserter: Clear your browser cache and any caching plugin. If you registered it via code, make sure the function is hooked to
initand that the category exists. - Pattern appears but is blank: Check the block markup. Use the block editor’s “Code editor� view (three-dot menu → Code editor) to copy the exact block markup and paste it into your PHP pattern.
- Changes to a pattern don’t update existing uses: Block patterns are static copies. When you insert a pattern, it’s copied into your content. To update all instances, you need to use a reusable block instead.
- Site error after adding code: Immediately deactivate the code by removing it from functions.php via FTP (or the theme editor). If you can’t access the admin, use FTP to edit the file.
Frequently Asked Questions
What’s the difference between a block pattern and a reusable block?
A block pattern is a saved layout that you insert as a copy—each time you add it, it’s independent. A reusable block is a single saved block (or group) that updates everywhere it’s used when you edit it once.
Can I use block patterns in the Classic Editor?
No. Block patterns require the block editor (Gutenberg). If you use the Classic Editor plugin, you won’t see the Patterns tab.
Do block patterns work with any theme?
Yes, patterns are theme-independent. However, the styling (fonts, colors, spacing) will inherit your theme’s global styles, so a pattern might look different from the preview if your theme uses custom colors.
Can I share a block pattern with someone else?
Yes. You can export the pattern as a JSON file (using the editor’s export option) and import it on another site. For code-based patterns, you can copy the PHP code and add it to the other site’s theme or a plugin.
Why can’t I see the “Create pattern� option in the editor?
This option appears only when you have multiple blocks selected. Also, make sure you’re using the latest version of WordPress (5.5+). If you still don’t see it, check that your browser is up to date.
Are there any performance issues with using many patterns?
Patterns themselves don’t slow down your site. The blocks they contain are the same as if you built them manually. However, using too many complex blocks on a single page can increase page size and load time, so optimize images and use caching.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.