• Resolved yann1ck

    (@ja4st3r)


    Hello support team,

    I love using GenerateBlocks and GeneratePress!

    I am currently building a new site using the new dynamic data feature. I am using the dynamic links to link to other sites. I would like to add link attributes like open links in a new tab, but I am not able to set link attributes for the dynamic links. Am I missing the option or is this just not possible?

    Thank you in advance.

    Kind regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support ying

    (@yingscarlett)

    Hi there,

    We can use the render block filter to achieve this.

    1. Add an additional CSS class to the headline block, eg. the-link.
    2. Add this filter:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( ! empty( $block['attrs']['className'] ) && $block['attrs']['className'] ==='the-link' ) {
            $block_content = str_replace( '<a ', '<a target="_blank" ', $block_content );
        }
    
        return $block_content;
    }, 10, 2 );

    Let me know if it works.

    Thread Starter yann1ck

    (@ja4st3r)

    Hi Ying,

    Thank you very much for the super fast response. It worked great.

    Kind regards
    Yannick

    Plugin Support ying

    (@yingscarlett)

    Glad to hear that 🙂

    Hi there! We haven’t heard back from you for a while now so we’re going to go ahead and set this topic as resolved. Feel free to reply if you need any more help.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Dynamic data link attributes’ is closed to new replies.