You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In includes/Field/BlockSupports/Anchor.php::register the field is resolved by retrieving the HTML for the block and returning the ID attribute set by Wordpress. This is returning null.
Within the $block array you can access ['attrs']['anchor'] which gives us the anchor tag without the need for decomposing the block. To test this I have replaced the resolve function with:
return $block['attrs']['anchor'];
This seems to work.
As I don't like to overwrite plugin code I have defined a new field, blockAnchor in my theme's functions.php - this can be accessed the same way the standard anchor field would be.
register_graphql_field('BlockWithSupportsAnchor', 'blockAnchor', [
'type' => 'string',
'description' => __('The anchor field for the block.', 'wp-graphql-content-blocks'),
'resolve' => static function ($block) {
return $block['attrs']['anchor'] ?? null;
}
]);
I origonally opened this ticket, wp-graphql/wpgraphql-acf#204, but Jason Bahl directed me to open one here instead.
Steps to reproduce
Anchors work for core blocks, but not for ACF blocks
The text was updated successfully, but these errors were encountered: