Open map bubble links in new tab

This topic contains 3 replies, has 3 voices, and was last updated by  Benjamin 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #438816

    Benjamin
    Full Member
    Post count: 67

    Hello,

    Is there anyway to make the map bubble links open into a new tab upon being clicked?
    I tried adding this jquery but it didn’t work:

    
    
    	$(document).ready(function(){
      $('.geodir-bubble_desc a').attr('target', '_blank');
    });

    If I remove the class, it targets every other link on the page but still not anything in the map bubbles.

    Thanks for any help!

    #438831

    Paolo
    Site Admin
    Post count: 31206

    Hi Benjamin,

    I’ve flagged your request for a developer. They’ll let you know asap.

    Thanks

    #438868

    Kiran
    Moderator
    Post count: 7069

    Hi Benjamin,

    Use following snippet to open post link in new window from map popup.

    
    
    function _gd_custom_link_to_new_window( $html, $post, $preview ) {
    	if ( ! empty( $html ) && ! empty( $post ) ) {
    		if ( ! empty( $post->ID ) ) {
    			$post_id = $post->ID;
    		} else if ( ! empty( $post->post_id ) ) {
    			$post_id = $post->post_id;
    		} else if ( ! empty( $post->pid ) ) {
    			$post_id = $post->pid;
    		} else {
    			$post_id = 0;
    		}
    		if ( $post_id > 0 ) {
    			$post_link = get_permalink( $post_id );
    			$html = str_replace( 'href="' . $post_link, 'target="_blank" href="' . $post_link, $html );
    		}
    	}
    	return $html;	
    }
    add_filter( 'geodir_custom_infowindow_html', '_gd_custom_link_to_new_window', 10, 3 );

    Thanks,
    Kiran

    #438935

    Benjamin
    Full Member
    Post count: 67

    This works great! Thanks.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket