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

    I want one of my masonry galleries to open the provided custom link in a new tab
    I followed instructions in another thread and it worked but then the blog posts in another masonry I have on my site also opened in a new tab (which is not the idea).
    Any ideas how to overcome this?
    Thanks!

    #1056271

    can you link to the page/post where you have that other thread?
    if it is by using the method to add the target blank thing.

    you can do it via an if clause for that page.
    Or you give a custom class to the masonry ALB Element f.e. newtab

    and then the jquery code would be for child-theme functions.php

    function open_masonry_in_tab(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('.av-masonry.newtab .av-masonry-entry').attr('target', '_blank');
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'open_masonry_in_tab');
    #1056274

    I tried what this thread suggested by pasting the code on my functions.php

    • This reply was modified 6 years, 1 month ago by saracoet.
    #1056277

    ok – then i misunderstood you.
    You got a masonry with no lightbox. But there are custom links on some images – and these have to open in new tab.

    #1056278

    thats right, sorry if I didn’t express myself correctly

    • This reply was modified 6 years, 1 month ago by saracoet.
    #1056283

    so you used ismaels code?
    and if this only on a specific page it would be nice to use it with an if clause on that page – because the script is then not loaded on the other pages.
    ( i just changed the function name to know better what is influenced on the script):

    add_action('wp_footer', 'open_customlinks_in_masonry_in_newtab');
    function open_customlinks_in_masonry_in_newtab(){
    if( is_page(35) ) {
    ?>
    <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
    }
    }

    so you have to know the ID of your page.

    Or if you use it with a custom class ( like above mentioned: newtab )

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

    then you have to give the masonry ALB that class

    #1056325

    Thanks for taking the time, I really appreciate it!
    the 2 masonries I use are on the same page, one is for blog posts and the other just an image gallery with links to other sites
    I want the blog posts from one masonry to open on the same tab but the ones from the image gallery with external links to open on a new tab.
    Since they are both on the same page, just to make sure I understand, you suggest I paste the 2nd code you provided in the Quick CSS and add “newtab” on the image gallery Masonry’s css class?

    I’ve tried it and it doesn’t seem to work

    Should I add the code to the functions.php via ftp or does that have the same result as adding the code to the Quick CSS?

    Sorry, I’m quite new to this :9

    • This reply was modified 6 years, 1 month ago by saracoet.
    #1056331

    but you said that it works fine with code from your link – so i thought you have done all right but only have troubles to select only one of them!

    That code above ( and then you will need the second one) comes to child-theme functions.php
    you will come to functions.php via dashboard – appearance – editor on the right there are “Theme files” click on functions.php
    All those snippets here from Board mostly comes to this file except css code ( which comes on common to quick css ).

    If you are not running a child-theme – you have here a lot of Theme files – and a function.php too.
    You can edit too – but you have to place those codes just after the comment lines on the bottom of the file:

    /*
     *  register custom functions that are not related to the framework but necessary for the theme to run
     */

    these custom snippets are lost everytime you update enfold – that is the reason for a child-theme use

    If it is placed – give a custom Class to the masonry where you want to have that new effect.

    Custom Class – you know how to activate the input field on Enfold.?

    #1056370

    Thanks I will look into child theme because I am not familiar with that.
    Thanks a lot for your help, I will let you know how it goes

    #1056428

    Hi,

    Thanks for the update, we’ll keep this thread open in case you should need any further help from us.

    Best regards,
    Rikard

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