Home › Forums › General Issues › How to register multiple ACF Gutenberg Blocks? › Reply To: How to register multiple ACF Gutenberg Blocks?
function register_acf_block_types() {
// 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'
));
}
// Check if function exists and hook into setup.
if( function_exists('acf_register_block_type') ) {
add_action('acf/init', 'register_acf_block_types');
}
I tried the same thing. When I add the Carousel in the editor I get just the Carousel, but when I try to add the Card, it shows the Carousel and the Card in the same block which I don’t want.
Anyone else having this problem? What am I missing?
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!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.