I’m struggeling in getting the anchor field to a new ACF-Block, with acf_register_block_type.
According to this page it should work: https://www.advancedcustomfields.com/resources/blocks/
'anchor' => true
'id' => true.
But it always just show me the class-name, not any anchor or id field.
Does anybody has an Idea what I’m making wrong?
I’ve got this answer from the ACF-Support.
Thank you for your email.
I hate to be the bearer of bad news but the acf_register_block_type() function currently does not support the ‘anchor’ property. You can have a look at its documentation here https://www.advancedcustomfields.com/resources/acf_register_block_type/.
I hope this helps and kindly let me know how this goes :).
@kopiczko-sebastian can confirm it works perfectly. Thanks for this!
acf_register_block_type( array( 'name' => 'countdown', 'title' => __('Countdown', TEXTDOMAIN), 'description' => __('A custom Countdown block.', TEXTDOMAIN), 'render_template' => 'template-parts/blocks/countdown.php', 'category' => 'my-custom-blocks', 'icon' => 'calendar-alt', 'keywords' => array( 'countdown', 'date', 'time' ), 'supports' => array( 'anchor' => true ) ) );
If it “works”, why ‘anchor’ doesn’t appears into parameters list of documentation?
Anchor IS indirectly mentioned in the documentation: the documentation states:
If you read the linked documentation at https://developer.wordpress.org/block-editor/developers/block-api/block-supports/ — anchor is the first parameter on the list.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!