Apply Custom Attribute to dynamic link on container

I am trying to apply a custom attribute to a dynamic link on a GB container (using Dynamic Data → Link Source)

The problem is, the data attribute is not applied to the a element inside the container, but instead gets applied to the parent container.

We are using Lity (a lightweight lightbox script) and in order for it to work, it’s important that the custom attribute is applied to the a element and not the parent.

How can I accomplish this?

Thank you,

@fernandoazarcon2 solved this for me.

  1. Add this to functions.php:
add_filter( 'render_block', function( $block_content, $block ) {
    if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'add-data-lity' ) !== false ) {
		$myreplace1 = '<a';
		$myinsert1 = '<a data-lity';
        $block_content = str_replace( $myreplace1, $myinsert1 , $block_content );

    return $block_content;
}, 10, 2 );
  1. Add the add-data-lity class on the container block under Advanced Settings

Thank you!

You’re welcome Joel!