| sidebar_position | 1 |
|---|
Understanding how the VIP Block Data API extracts block attributes from HTML.
The plugin supports all WordPress attribute sources:
Extracts HTML element attributes:
{
"url": {
"type": "string",
"source": "attribute",
"selector": "img",
"attribute": "src"
}
}Extracts inner HTML content:
{
"content": {
"type": "string",
"source": "html",
"selector": "p"
}
}Extracts plain text content:
{
"citation": {
"type": "string",
"source": "text",
"selector": "cite"
}
}Extracts arrays of data:
{
"images": {
"type": "array",
"source": "query",
"selector": "img",
"query": {
"url": {
"type": "string",
"source": "attribute",
"attribute": "src"
},
"alt": {
"type": "string",
"source": "attribute",
"attribute": "alt"
}
}
}
}For custom blocks, server-side registration with block.json is required:
register_block_type( __DIR__ . '/build/custom-block' );