Home Forums Gutenberg Block styles not saved ?


Block styles not saved ?

  • 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:

    Styles selector

    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..

  • Did You tried without templateLock="all" ?

  • I made simple test with nested blocks + native styles – with and without clocking template. I’m correct at some point – it’s working without locking template like above.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.