Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

query loop a href target=”_blank”

  • I use generateblocks query loop, but when I click on the link, it doesn’t open in a new window. Is there a taget blank option?

    If not, is there a way to make only the generateblocks query loop link open in a new window?

  • Hi there,

    1. Add this PHP Snippet to your site:

    
    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'open-in-new-tab' ) !== false ) {
    	$myreplace = '<a';
    	$myinsert = '<a target="_blank" ';
            $block_content = str_replace( $myreplace, $myinsert , $block_content );
        }
    
        return $block_content;
    }, 10, 2 );
    

    2. select the block with the dynamic link and in Advanced > Additional CSS Classes add: open-in-new-tab

  • Hi David,
    Any chance this will be added via the UI?

    Dan

  • Hi there,

    yes, its on our list of to dos.
    Once have the latest alphas out the way we will be revisiting legacy features requests such as this.

  • Great, thanks!

  • You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.