Home › Forums › Gutenberg › Registering an array of Gutenberg blocks › Reply To: Registering an array of Gutenberg blocks
You should be able to call acf_register_block()
(which has been renamed to acf_register_block_type()
in 5.8.0 release) multiple times in a row without any issues.
I think the issue might be that the $blocks
variable does not contain the blocks data.
try to do the end of the blocks file like so:
// blocks.php
..
$blocks = [
$headline,
$paragraph
];
return $blocks;
You can then get the value like so:
// index.php
function block_acf_init()
{
$blocks = require(__DIR__.'/blocks.php');
foreach($blocks as $block) {
acf_register_block($block);
}
}
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.