Adding HTML Anchor in Custom ACF Blocks

To add functionality that allows you to add an HTML (ID) anchor to a section, add the following supports when you register your custom ACF block:

'supports' => array( 'anchor' => true ),

Remember to add it to your markup using:

id="<?php echo esc_attr( $block['anchor'] ); ?>"

Comments

2 responses to “Adding HTML Anchor in Custom ACF Blocks”

  1. JM Avatar
    JM

    Thanks so much! this was super helpful. I needed a quick reference to add anchor links.

Leave a Reply

Your email address will not be published. Required fields are marked *