Vincent's blog

Flexible Gutenberg blocks

I discovered that I could create Gutenberg blocks, similar to the Flexible Content Field offered by Advanced Custom Fields, by disabling preview mode in the block's JSON file.

"acf": {
  "mode": "edit",
}

Include an Accordion Field as the initial element in the field group. To illustrate, here is an example from the Extended ACF package:

$block = register_block_type(__DIR__ . '/block.json');

register_extended_field_group([
    'title' => $block->name,
    'fields' => [
        Accordion::make($block->title)->open(),
        Text::make('Label'),
    ],
    'location' => [
        Location::where('block', $block->name)
    ],
]);

For complete control over the editing process, I suggest disabling any additional blocks available in Gutenberg.

example of flexible Gutenberg content blocks

#wordpress