Integrated Pattern Block
Description
The Integrated Pattern Block renders WordPress block patterns by their slug rather than their database ID. This ensures that pattern references remain valid across different environments (development, staging, production) where pattern IDs may differ, but pattern slugs stay consistent.
Features
- Slug-Based References - Uses pattern slugs instead of database IDs
- Environment Portable - Works across different database instances
- Template Safe - Safe to use in template files and patterns
- Block Pattern Trait - Includes helper methods for pattern management
- No Default Wrapper - Complete control over HTML output
- Utility Category - Grouped with other utility blocks
- Auto-initialized - Available immediately without manual initialization
Utility Block
This block is automatically initialized by the plugin and ready to use. Simply add it in the block editor or include it in your block template structures. Do not extend utility blocks - they are designed to be used directly as-is.
Use Cases
Post Template with Pattern
Render a consistent post card pattern for each post in a query loop.
// Use the block in your template:
array(
'core/post-template',
array(),
array(
array(
'acf/integrated-pattern',
array(
'data' => array(
'block_pattern' => 'post-card',
),
),
),
),
)
Reusable Section Pattern
Include a reusable section pattern in multiple templates.
// In any template or pattern:
array(
'acf/integrated-pattern',
array(
'data' => array(
'block_pattern' => 'cta-section',
),
),
)
Why Use This Block?
The Problem
WordPress patterns are stored as custom posts with database IDs. When template files are used on multiple environments, these IDs change, breaking your template references.
// ❌ Core pattern block - breaks on database sync
array(
'core/block',
array('ref' => 456), // This ID won't exist on other environments
)
The Solution
Integrated Pattern Block references patterns by slug, which is consistent across environments.
// ✅ Integrated Pattern - works everywhere
array(
'acf/integrated-pattern',
array(
'data' => array(
'block_pattern' => 'hero-section', // Slug is the same everywhere
),
),
)
Related Blocks
- Post Listing Block - Often used together for post displays
- Integrated Menu Block - Menu integration counterpart
Best Practices
- Consistent Slugs - Use consistent, descriptive slugs for patterns across all environments
- Documentation - Document which pattern slugs your theme requires
- Testing - Test pattern rendering across all environments
- Fallbacks - Consider what happens if a pattern doesn't exist
- Categories - Organize patterns into logical categories for easier selection