Support

Account

Home Forums General Issues How to register multiple ACF Gutenberg Blocks? Reply To: How to register multiple ACF Gutenberg Blocks?

  • This is an alternative, it does the same thing as the other version I posted but when I create a Card block, I’m still getting the Carousel block appearing below the Card block in the editor, they appear together as if they were all one block

    However, if I add the Carousel block, it is just the Carousel which is expected. I have scoured the Internet and have yet to find out how to create multiple ACF blocks.

    Seems like you’d just register a new block and it should work but I’m having issues when adding the Card block and it including the Carousel block along with it.

    
    add_action('acf/init', 'my_acf_blocks_init');
    function my_acf_blocks_init() {
    
      // Check function exists.
      if( function_exists('acf_register_block_type') ) {
    
      	// register a Carousel block
      	acf_register_block_type(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_type(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'
      	));
      }
    }