How to Register Multiple ACF Blocks?
-
Using this below, I’m able to register 3 different custom blocks. The main problem I can’t figure out is why the Card block and the Section block both get the Carousel block attached with them in the editor instead of simply appearing by themselves.
It’s so weird but I can’t see where the problem is. The Carousel block appears alone in the editor and works right. The Card and Section blocks in the editor both have the Carousel with them. Weird. Any takers?
add_action('acf/init', 'my_acf_init'); function my_acf_init() { // Check function exists. if( function_exists('acf_register_block') ) { // register a Carousel block acf_register_block(array( 'name' => 'carousel', 'title' => __('Carousel'), 'description' => __('Show images in a carousel'), 'render_template' => 'blocks/carousel.php', 'category' => 'common', 'icon' => 'slides', 'keywords' => array( 'carousel', 'gallery'), 'mode' => 'edit' )); // register a Card block acf_register_block(array( 'name' => 'card', 'title' => __('Card'), 'description' => __('Card with photo and info'), 'render_template' => 'blocks/card.php', 'category' => 'common', 'icon' => 'id', 'keywords' => array( 'card', 'team' ), 'mode' => 'edit' )); // register a Section block acf_register_block(array( 'name' => 'section', 'title' => __('Page Section'), 'description' => __('Page section with title and description'), 'render_template' => 'blocks/section.php', 'category' => 'common', 'icon' => 'excerpt-view', 'keywords' => array( 'section' ), 'mode' => 'edit' )); } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to Register Multiple ACF Blocks?’ is closed to new replies.