Support

Account

Home Forums Gutenberg ACF Blocks in a child theme

Solved

ACF Blocks in a child theme

  • Is it possible to use ACF Blocks in a child theme? I’m using ACF 5.8 and the following code dropped into the functions.php file, from the ACF Blocks docs:

    if( function_exists('acf_register_block') ) {
       add_action('acf/init', 'register_acf_blocks');
    }

    This does not result in “Block” showing up the “Show this field group- if…” menu.

    Also tried the pluggable way for a child theme:

    if ( ! function_exists( 'acf_register_block' ) ) {
      function acf_register_block() {
        add_action('acf/init', 'register_acf_blocks');
      }
    }

    Same result.

    Removing the function_exists check results in the error Fatal error: Uncaught Error: Call to undefined function acf_register_block().

    Any ideas?

    Thanks

  • OK, so using a newer version of 5.8 (5.8.0-beta4) resulted in the “Blocks” item showing in the location menu, and this way of adding the function for the child theme ensures the block shows up in the list:

    if ( ! function_exists( 'acf_register_block' ) ) {
      add_action('acf/init', 'register_acf_blocks');
    }
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF Blocks in a child theme’ is closed to new replies.