Home › Forums › Gutenberg › Programatically registering ACF field blocks in Gutenberg › Reply To: Programatically registering ACF field blocks in Gutenberg
It seems that underscores in block name isn’t passing though.
So, textarea_block
as a block name is not working, instead use a name without underscores, something like textareablock
.
Try this:
if( function_exists('acf_register_block') ) {
acf_register_block(array(
'name' => 'textareablock',
'key' => 'textarea_block',
'title' => __('textarea'),
'description' => __('A custom pixel block.'),
'render_callback' => 'textarea_block_render_callback',
'category' => 'formatting',
'mode' => 'edit', // 'preview',
'icon' => 'admin-comments',
'keywords' => array( 'flexible', 'quote' ),
));
}
register_field_group(array (
'key' => 'textarea',
'title' => 'Text Area',
'fields' => array(
array(
'key' => 'textarea_title',
'name' => 'textarea_title',
'label' => 'Section Title',
'instructions' => '',
'type' => 'text',
),
array(
'key' => 'textarea_text',
'name' => 'textarea_text',
'label' => 'Text',
'instructions' => '',
'type' => 'wysiwyg',
),
),
'location' => array (
array (
array (
'param' => 'block',
'operator' => '==',
'value' => 'acf/textareablock'
),
),
),
));
P.S. I’ve added 'mode'=> 'edit'
to start ACF block in edit more.
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.