Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #919835

    Hi,
    I’d like all masonry gallery links open in new tab with the attribute “nofollow”. How can I do it?

    • This topic was modified 6 years, 9 months ago by Monica.
    #920244

    Hey mstasik,

    Thank you for using Enfold.

    The gallery items will open a lightbox unless a “Custom Link” is specified. Do you want to disable the lightbox feature?

    Best regards,
    Ismael

    #921599

    Most of my masonry galleries will not have links and will need to keep lightbox enabled. Just in selected masonry galleries I’d like to add links to external websites (see the second gallery on my website where I present computers and logotypes of my clients). When I add “Custom Link” the lightbox is disabled (this is OK, works fine, this does not need to be changed) and the links work fine and open the relevant websites. But I’d like the masonry gallery with links to open the links in NEW TABS and have attribute NOFOLLOW. Now the links from masonry gallery are opened in the same tab, so users are leaving my website which I do not want.

    #922207

    Hi,

    Thank you for the info.

    This script will apply the target and rel attributes to the masonry items with custom links. Just add the code inside the functions.php file.

    add_action('wp_footer', 'ava_custom_script');
    function ava_custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
        function a() {
            $('.av-masonry-entry:not(".lightbox-added")').each( function() {
                $(this).attr('target', '_blank');
                $(this).attr('rel', 'nofollow');
            });
        }
        
        a();
    })(jQuery);
    </script>
    <?php
    }

    Best regards,
    Ismael

    #922305
    This reply has been marked as private.
    #922320

    Hi mstasik,

    Yes, please remove the last closing php descriptor. You will have to do it via FTP.

    Best regards,
    Victoria

    #922345

    Hi Victoria,
    website displays content again, but the added script regarding links in masonry gallery with “custom links” ( I wanted the “custom links” _blank & nofollow) does not work.

    #924033

    Hi,

    Can you please use the code as following
    https://pastebin.com/nwejyRCh

    seems that the ‘ was not properly and it was replaced because of forums.

    Thank you

    Best regards,
    Basilis

    #924345

    Hi, I’ve used your code, but still the links from masonry gallery are opened in the same tab. Is there anything we could do about it?

    #924523

    Hi mstasik,

    Can you please enable Appearance > Editor for now?
    Here is how to do it

    Best regards,
    Victoria

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