Support

Account

Home Forums Gutenberg acf_add_local_field_group: fields dont appear in Gutenberg block Reply To: acf_add_local_field_group: fields dont appear in Gutenberg block

  • I found a bug and fix it.
    YOu are not able to use underscore in block name when you set locations for acf_add_local_field_group

    Instead just replace all underscore with simple score and it will work.

    acf_register_block( [
    ‘name’ => ‘test_any’,
    ‘title’ => ‘Test’,
    ‘render_callback’ => function() {
    ?>
    <h2>123</h2>
    <?php
    }
    ] );

    acf_add_local_field_group(array(
    ‘key’ => ‘block_test’,
    ‘title’ => ‘Block Test’,
    ‘active’ => 1,
    ‘fields’ => array (
    array (
    ‘key’ => ‘field_1’,
    ‘label’ => ‘Sub Title’,
    ‘name’ => ‘sub_title’,
    ‘type’ => ‘text’,
    )
    ),
    ‘location’ => array (
    array (
    array (
    ‘param’ => ‘block’,
    ‘operator’ => ‘==’,
    ‘value’ => ‘acf/test-any’,
    ),
    ),
    ),
    ));