Registering field for block does not work
-
I created a block with acf_register_block_type which shows the block in editor which is complete fine. I did that this way,
//custom block with acf function mab_register_acf_block_types() { acf_register_block_type( [ 'name' => 'blockquote', 'title' => __( 'Blockquote' ), 'description' => __( 'My blockquote block.' ), 'render_template' => dirname( __file__ ) . '/blocks/blockquote/blockquote.php', 'category' => 'formatting', 'icon' => 'format-quote', ] ); } if ( function_exists( 'acf_register_block_type' ) ) { add_action( 'acf/init', 'mab_register_acf_block_types' ); }
But I wanted to register the field for this block which actually does not work. The registration of field done this way
add_action('acf/init', function () { if( function_exists('acf_add_local_field_group') ): acf_add_local_field_group(array ( 'key' => 'group_1', 'title' => 'My Group', 'fields' => array ( array ( 'key' => 'field_1', 'label' => 'Sub Title', 'name' => 'sub_title', 'type' => 'text', 'prefix' => '', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array ( 'width' => '', 'class' => '', 'id' => '', ), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0, ) ), 'location' => array ( array ( array ( 'param' => 'block', 'operator' => '==', 'value' => 'blockquote', ), ), ), 'menu_order' => 0, 'position' => 'normal', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', )); endif; });
If I set the location to something else like post_type , it is okay, which means the code for registering the field is working for post_type but if I set the location to block == ‘blockquote’, it’s not working. Is there anything wrong I am doing or is it the bug of acf ?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Registering field for block does not work’ is closed to new replies.