Blockstudio
Pages & Patterns

Patterns

Patterns are file-based templates registered as WordPress block patterns. They appear in the block inserter and can be placed anywhere by users.

Unlike pages, patterns are registered in memory and don't create database entries.

pattern.json

Each pattern folder needs a pattern.json configuration file:

pattern.json
{
  "name": "hero-section",
  "title": "Hero Section",
  "description": "A hero section with heading and CTA",
  "categories": ["featured", "header"],
  "keywords": ["hero", "banner", "cta"]
}

Properties

PropertyTypeDefaultDescription
namestringrequiredUnique identifier (prefixed with blockstudio/)
titlestringrequiredDisplay title in the block inserter
descriptionstring""Description shown in the inserter
categoriesstring[][]Pattern categories (e.g., featured, header, footer)
keywordsstring[][]Search keywords for the inserter
viewportWidthnumber-Preview width in pixels
blockTypesstring[][]Associated block types
postTypesstring[][]Restrict to specific post types
inserterbooleantrueWhether to show in the inserter

Example

pattern.json:

{
  "name": "hero-with-cta",
  "title": "Hero with CTA",
  "description": "A full-width hero section with heading and call-to-action buttons",
  "categories": ["featured", "header"],
  "keywords": ["hero", "banner", "cta", "landing"],
  "viewportWidth": 1200
}

index.php:

<block name="core/cover" url="https://example.com/hero-bg.jpg" dimRatio="60">
  <h1>Build Something Amazing</h1>
  <p>Create beautiful websites with the power of blocks.</p>
  <block name="core/buttons">
    <block name="core/button" url="/get-started">Get Started</block>
    <block name="core/button" url="/learn-more" className="is-style-outline">Learn More</block>
  </block>
</block>

Custom Paths

By default, Blockstudio scans get_template_directory() . '/patterns'. Add additional paths with the filter:

add_filter( 'blockstudio/patterns/paths', function( $paths ) {
    $paths[] = get_stylesheet_directory() . '/custom-patterns';
    $paths[] = MY_PLUGIN_PATH . '/patterns';
    return $paths;
} );

PHP API

// Get all registered patterns
$patterns = Blockstudio\Patterns::patterns();

// Get a specific pattern
$pattern = Blockstudio\Patterns::get_pattern('hero-section');

// Get registered paths
$paths = Blockstudio\Patterns::get_registered_paths();

Comparison with Pages

PagesPatterns
StorageSynced to database as postsRegistered in memory
Configpage.jsonpattern.json
SyncAuto-syncs on file changeNo sync needed
Template lockYesNo
Use casePredefined page contentReusable block templates

On this page