Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect Block to ACF field group #48

Open
Sandrio84 opened this issue Apr 20, 2021 · 2 comments
Open

Cannot connect Block to ACF field group #48

Sandrio84 opened this issue Apr 20, 2021 · 2 comments

Comments

@Sandrio84
Copy link

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 }}
<style type="text/css"> [data-{{ block.id }}] { background: {{ fields.background_color }}; color: {{ fields.text_color }}; } </style>
@jamacon36
Copy link

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 );

@palmiak
Copy link
Owner

palmiak commented Jul 9, 2021

@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 );
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants