Hi,
If created a grid block with innerblocks for the columns. I’f added styles to the block.json like this:
"styles": [
{ "name": "1kolom", "label": "1 kolom" },
{ "name": "2kolommen", "label": "2 kolommen" },
{ "name": "3kolommen", "label": "3 kolommen", "isDefault": true },
{ "name": "4kolommen", "label": "4 kolommen" }
],
This shows style options for the block like this:
Now in my php file for the block, I render my Innerblocks template, based on the selected style:
if( $block['className'] === "is-style-1kolom") {
$template[] = array('acf/kolom');
}
elseif( $block['className'] === "is-style-2kolommen") {
$template[] = array('acf/kolom');
$template[] = array('acf/kolom');
}
The template is used to show 1, 2, 3 or 4 columns:
<?php echo '<InnerBlocks template="' . esc_attr(wp_json_encode($template)) . '" templateLock="all" />'; ?>
This all works well, except for one thing.
When I select a block style, the value is not saved when saving a page.
Does anyone know what is causing this issue?
I can’t find any documentation about working with block styles..