Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1420589

    I have added the code in the child functions.php file (as suggested here: https://kriesi.at/support/topic/how-to-masonry-items-open-in-a-new-window/?login_error) but portfolio items won’t open in a new window from the Masonry Grid. Do I need to do anything else or is that all – add the below code in functions.php?

    Code: function masonry_links () {
    ?>
    <script>
    window.addEventListener(‘DOMContentLoaded’, function() {
    (function ($) {
    $(document).ready (function () {
    var url = new RegExp(location.host);

    $(‘.av-masonry-entry’).each(function () {
    if( ! url.test($(this).attr(‘href’)) ) {
    $(this).attr(‘target’, ‘_blank’);
    }
    });
    });
    }) (jQuery);
    });
    </script>
    <?php
    }
    add_action (‘wp_footer’, ‘masonry_links’);

    #1420637

    Hi ElizabethEnglish,

    The code provided will only open masonry links in new tab if they are external link.
    To change it’s behavior to include all links, please change it to:

    function masonry_links () {
    ?>
    <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function ($) {
        $(document).ready (function () {
            var url = new RegExp(location.host);
    
            $('.av-masonry-entry').each(function () {
                $(this).attr('target', '_blank');
            });
        });
    }) (jQuery);
    });
    </script>
    <?php
    }
    add_action ('wp_footer', 'masonry_links');

    Hope it helps.

    Best regards,
    Nikko

    #1420681

    That works! Thank you!

    #1420683

    Hi ElizabethEnglish,

    I’m glad that we could help you :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Portfolio items won’t open in a new window from the Masonry Grid.’ is closed to new replies.