Home Forums Gutenberg acf_register_block_type() throwing errors in vscode


acf_register_block_type() throwing errors in vscode

  • 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(){
    			'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'),


  • 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(){
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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.