BlocksAttributes
Block Attributes
The $attributes or $a variables only give you access to data registered in the blockstudio property. To access standard WordPress block data like alignment or typography, use the $block or $b variables.
Rendering
<h1>The block is aligned: <?php echo $block['align']; ?></h1>
<h1>The block is aligned: <?php echo $b['align']; ?></h1><h1>The block is aligned: {{ block.align }}</h1>
<h1>The block is aligned: {{ b.align }}</h1>Setting Defaults
To set a default value for WordPress properties like align, add a default key inside the attributes key:
{
"$schema": "https://blockstudio.dev/schema/block",
"name": "blockstudio/block",
"title": "Native Block",
"icon": "star-filled",
"description": "Native Block.",
"supports": {
"align": ["left", "center", "right"]
},
"attributes": {
"align": {
"type": "string",
"default": "center"
}
},
"blockstudio": true
}Available Block Data
The $block / $b variable contains:
| Property | Description |
|---|---|
name | Block name (e.g., my-theme/my-block) |
title | Block title |
dir | Block directory path |
url | Block directory URL |
align | Alignment value (if supports.align is enabled) |
className | Custom CSS class (if supports.customClassName is enabled) |
anchor | HTML anchor/ID (if supports.anchor is enabled) |
WordPress Supports
Enable WordPress block features via the supports property:
{
"supports": {
"align": true,
"anchor": true,
"customClassName": true,
"color": {
"background": true,
"text": true
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true
}
}
}See the WordPress Block Supports documentation for all available options.