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

    Hi Guys
    I’m trying to get links in my masonry gallery to open in a new window.
    I found this code in a previous topic (#281007) and tried adding it to the very end of my functions.php in the appearance editor.

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
    jQuery(‘.av-masonry a’).each(function(){
    jQuery(this).attr(‘target’, ‘_blank’);
    });
    });
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘add_custom_script’);

    Links still open in the same window though. Should I maybe add the code at another location in functions.php?

    #463174

    Hi graphicsplus!

    Thank you for using Enfold.

    Please try this:

    function add_custom_script(){
    ?>
    <script>
      jQuery('.av-masonry-entry').each(function() {
        jQuery(this).attr('target', '_blank');
      });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Regards,
    Ismael

    #464276

    Hi Ismael,
    I’ve added your code to the very end of my functions.php (outside the last brackets) using the appearance editor. But the links still open in the same window…

    #464281

    Hey!

    Do you mind creating a temporary admin login and posting it here privately so we can look into it?

    Best regards,
    Yigit

    #464284

    Of course, be my guest!

    It concerns the 5 sponsor logo’s at the very bottom of the homepage, just above the footer.

    #464290

    Hey!

    I fixed the code. Can you please try it now?

    Best regards,
    Yigit

    #464549

    Hi Yigit,

    Thanks! That worked great. I see I put the code in the wrong file. I put it in functions-enfold.php instead of theme functions.

    #465167

    Hi!

    Great, glad you got it fixed :)

    Regards,
    Rikard

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