Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #938435

    Hello, all
    I’ve been looking at several posts, trying to avoid bothering you with this request, but I have built a page with a masonry gallery element that links directly to PDFs, so I would like the link to be a blank target.
    I’ve tried adding the js into the header.php but it’s not working. Please advise and thank you in advance :)

    #938857

    Hey webWahine,
    please try this script in a code block element on your page:

     
    <script>
    jQuery(window).load(function(){
    jQuery('.av-masonry-container a ').attr('target','_blank');
    });
    </script>

    I tested on the page in Private Content area, and it seems to work.

    To use as a function in your functions.php file in Appearance > Editor:

     function add_custom_target(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery('.av-masonry-container a ').attr('target','_blank');
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_target');

    It is important to note that the lightbox option at Enfold Theme Options > Lightbox Modal Window needs to be unchecked.

    Best regards,
    Mike

    #938866

    thank you – the code block js worked! I actually tried that before and it didn’t so perhaps I just had something stuck in my cache. So, to confirm, I can use one or the other option since the code block is working as is? Would unchecking the lightbox modal effect all other lightbox elements, eg, portfolio items? :)

    #938890

    Hi,
    Good to hear, you can use just one or the other, if the code block is working, then use it. I like to put as much as I can in the answers because other people will read this months from now. This is also why I added the note about unchecking the lightbox modal effect, because it is the only way I could get it to work on my localhost, and when testing on your site I assumed you already had it unchecked. Is this true?
    But to answer you, yes unchecking the lightbox modal effect will effect other elements on your site.

    Best regards,
    Mike

    #938902

    Hi Mike
    I totally agree – I always put my code in here to help others, and look at as many posts as possible to find the answer before I bother you :)
    I realised that I did have a slightly different js that didn’t work from another post but it was from a while ago, so yours is perfect! Thanks about the modal check box – it is actually checked but I like the js option on each page in case I need to target portfolio items in a different way, ie, not in a blank loader. Thank you! :)

    #938918

    Hi,
    Very good, unless there is anything else we can help with shall we close this then?

    Best regards,
    Mike

    #938920

    Yes, thank you very much, Mike!

    #938922

    Hi,
    Glad we were able to help, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    and the video tutorials here
    And if there are features that you wish Enfold had, you can request them and vote the requested ones here
    For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Open masonry gallery image link in a new window’ is closed to new replies.