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’,
),
),
),
));
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.