timber-acf-wp-blocks icon indicating copy to clipboard operation
timber-acf-wp-blocks copied to clipboard

Cannot connect Block to ACF field group

Open Sandrio84 opened this issue 5 years ago • 2 comments

Hi, I have an issue when creating a new custom field group. I'm using ACF PRO 5.9.5 and WordPress 5.7. When adding the install to my theme I cannot add the Block in ACF (Show this field group if 'Block' is equal to ... ) I used the install (composer require "palmiak/timber-acf-wp-blocks") when I'm in the 'dist' folder. Am I doing something wrong?

My theme structure: dist:

  • composer.json
  • vendor
    • composer
    • palmiak
  • wp-content
    • plugins
      • timber
    • themes
      • cec-theme
        • views
          • blocks
            • testimonial.twig

-- Testimonial.twig code -- {# Title: Testimonial Description: Customer testimonial Category: formatting Icon: admin-comments Keywords: testimonial quote "customer testimonial" Mode: edit Align: left PostTypes: page post SupportsAlign: left right SupportsMode: false SupportsMultiple: false #}

{{ fields.testimonial }}

{{ fields.author }}

Sandrio84 avatar Apr 20 '21 12:04 Sandrio84

FWIW: I too was running into this and as a workaround the following worked:

// In functions.php
add_action( 'acf/init', 'timber_block_init', 10, 0 );

jamacon36 avatar Jun 01 '21 16:06 jamacon36

@Sandrio84 @jamacon36 - are both of you using Timber as a plugin rather than a composer library?

If so I would probably have to check if users are using plugin or library and change this part a bit:

public function __construct() {
	if ( is_callable( 'add_action' )
		&& is_callable( 'acf_register_block_type' )
		&& class_exists( 'Timber' )
		) {
		add_action( 'acf/init', array( __CLASS__, 'timber_block_init' ), 10, 0 );
	}
}

palmiak avatar Jul 09 '21 16:07 palmiak