
I have written and rewritten the acf custom block build in two different projects and continue to run into an error with the ‘acf_register_block_type()’ specifically. It throws this error every time, ‘Undefined function acf_register_block_type. I have followed the documentation as well at following along with a few tutorials to see if I am missing something and so far have had no luck hunting down whats causing this.
It should be noted that I am really new to wp and acf but I do have a bit of dev experience outside of this. I also recently updated WP to rule that out as the cause.
This is my code.
if (function_exists('acf_register_block_type')) {
add_action('act/init', 'register_acf_block_types');
}
function register_acf_block_type(){
acf_register_block_type(
array(
'name' => 'new_block',
'title' => __('New Block'),
'description' => __(' A custom block.'),
'render_template' => 'template-parts/blocks/new/new.php',
'icon' => 'editor-paste-text',
'kewyword' => array('production', 'toaster'),
)
);
}
PLEASE HELP ME, IM LOSING MY MIND.
It does not make any sense why you would be getting an error that a function does not exist when you check for its existence before calling it.
But the function you are registering:
add_action('act/init', 'register_acf_block_types');
is not the same as the function you want to call:
function register_acf_block_type(){