Archived topic
Dynamic Image: open link in new window
1 reply · Started by Stephane Bergeron on October 25, 2021
Hi,
I'm wondering if there's a setting I'm overlooking but I'M trying to use a Dynamic Image block in a GPP content template and I'm using a Pods URL field for the Dynamic Image block but, since these URLs are to external sites, I'd want to open the link in a new tab using standard target="_blank" but I see no setting to specify to open the dynamic link in a new window.
If that is not possible, consider this a feature request ;) If it is possible, how?
THanks!
Hi Stephane,
Give this PHP snippet a try:
add_filter( 'render_block', function( $block_content, $block ) {
if ( 'generatepress/dynamic-image' === $block['blockName'] ) {
$block_content = str_replace( '<a ', '<a target="_blank" ', $block_content );
}
return $block_content;
}, 10, 2 );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know :)