Support

Account

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

  • Apologies if this comes as duplicate posts. I have posted twice but did not go through.

    I got a white editor page after I added the second register block. I got the editor back when I removed it and I am not sure what’s wrong as written. I will appreciate some help.

    function register_acf_block_types() {
    
       // register a testimonial block.
       acf_register_block_type(array(
          'name'              => 'testimonial',
          'title'             => __('Testimonial'),
          'description'       => __('A custom testimonial block.'),
          'render_template'   => 'template-parts/blocks/testimonial/testimonial.php',
          'category'          => 'formatting',
          'icon'              => 'admin-comments',
          'keywords'          => array( 'testimonial', 'quote' ),
       ));
    	
    	// register a testimonial block.
       acf_register_block_type(array(
          'name'              => 'landing_page_content',
          'title'             => __('Landing Page'),
          'description'       => __('A custom landing page block.'),
          'render_template'   => 'template-parts/blocks/landing/page_landing.php',
          'category'          => 'formatting',
          'icon'              => 'dashicons-format-aside',
          'keywords'          => array( 'landing', 'card' ),
       ));
    }
    
    // Check if function exists and hook into setup.
    if( function_exists('acf_register_block_type') ) {
      add_action('acf/init', 'register_acf_block_types');
    }