wp-graphql-gutenberg-acf
wp-graphql-gutenberg-acf copied to clipboard
Latest ACF issue
https://github.com/pristas-peter/wp-graphql-gutenberg-acf/blob/develop/plugin.php#L86
$root['attributes']['id']
should be updated with
$root['postId']
If there are no inner blocks. There should be some check for inner blocks or just simple check like this
$inner_id = $root['postId'];
if (array_key_exists('id', $root['attributes'])) {
$inner_id = $root['attributes']['id'];
}
acf_setup_meta(
$root['attributes']['data'],
$inner_id,
false
);
return $inner_id;
ACF Pro 6.0.3
Also there is no release with latest updates.
The solution @marziolek works. However, whenever you have the same block on the page. It duplicates the data. Any fixes for that? As you can see I have the Story Block twice on the same page and the data is duplicated.
https://github.com/pristas-peter/wp-graphql-gutenberg-acf/blob/develop/plugin.php#L86
$root['attributes']['id']
should be updated with$root['postId']
If there are no inner blocks. There should be some check for inner blocks or just simple check like this$inner_id = $root['postId']; if (array_key_exists('id', $root['attributes'])) { $inner_id = $root['attributes']['id']; } acf_setup_meta( $root['attributes']['data'], $inner_id, false ); return $inner_id;
ACF Pro 6.0.3
Hey @marziolek, this solution seem to solve the "null" result issue, but like @JoeStantonCode, when you use a block twice in the same page, all fields take the first block iteration as value.
Append with ACF Pro@6
@MKlblangenois do you have any suggestions on how we can handle repeaters? We are trying to pull in repeater data from an ACF Options screen and still reciving null values.
{footerBlocks.map((item: any, key: any) => ( <div className="contact-form-footer__item" key={key}> <b>{parse(item.headline)}</b> {parse(item.text)} </div> ))}
footerBlocks
being the repeater.
The solution @marziolek works. However, whenever you have the same block on the page. It duplicates the data. Any fixes for that? As you can see I have the Story Block twice on the same page and the data is duplicated.
Hi, I got the same issue regarding duplicates data. Do you guys have any workaround to solve this? Thank you
For anyone who still looking for solution of duplicate value issue, this code might help.
add_filter( 'acf/pre_save_block', 'add_acf_block_identifier' );
function add_acf_block_identifier( $attributes ) {
if ( empty( $attributes['id'] ) ) {
$attributes['id'] = 'acf-block-' . uniqid();
}
return $attributes;
}
Add this block code to your functions.php on your theme or create a custom wordpress plugin.
This issue caused by missing block id on Custom Gutenberg Block by ACF, since ACF 6.0 no longer save block IDs. Ref to this article here
Hope this will help other. Happy coding :)