Home › Forums › General Issues › How to register multiple ACF Gutenberg Blocks? › Reply To: How to register multiple ACF Gutenberg Blocks?
Is this the correct way:
function register_acf_block_types() {
// register a Post-Grid block.
acf_register_block_type(array(
'name' => 'post-grid',
'title' => __('Post-Grid'),
'description' => __('A custom Post-Grid block.'),
'render_template' => 'blocks/post-grid/block-post-grid.php',
'category' => 'common',
'icon' => 'grid-view',
'keywords' => array( 'post-grid', 'grid', 'post', 'posts' ),
));
// register a Post-List block.
acf_register_block_type(array(
'name' => 'post-list',
'title' => __('Post-List'),
'description' => __('A custom Post-List block.'),
'render_template' => 'blocks/post-list/block-post-list.php',
'category' => 'common',
'icon' => 'list-view',
'keywords' => array( 'post-list', 'list', 'post', 'posts' ),
));
}
// Check if function exists and hook into setup.
if( function_exists('acf_register_block_type') ) {
add_action('acf/init', 'register_acf_block_types');
}
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.