Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #744493

    Hi, I’m using the Masonry Gallery for different parts of my website however I need the gallery to open up some links in a new window and some in the same window.

    For example on my home page the gallery opens a link in the same window however when I use the gallery on other pages I want the links to open in a new window/tab. I initially searched the forum and found the following code which makes the links to open in a new window however this makes the entire Masonry Gallery to open all links in a new window regardless of what page I use it in:

    ==================================
    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’);
    ==================================

    I would like to know if there is any solution to have either one of those options. I have included the sample pages in the PRIVATE CONTENT. I would appreciate if you guys can help me out regarding this issue.

    Thanks again!

    #744537

    Hi aliakbari2!

    Can you please share us backend access so we can check your functions.php file?

    Thanks a lot

    Cheers!
    Basilis

    #744545

    Thanks for the reply, the login information is available in the PRIVATE CONTENT section.

    #746553

    Hi again, were you able to login to the account to analyze the FUNCTIONS.php file by any chance? Thanks.

    #746615

    Hi,

    you could try to work with WordPress’ conditional functions:
    https://codex.wordpress.org/Conditional_Tags

    Best regards,
    Andy

    #750530

    Hi,
    you can target pages

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

    #752351

    @demarko19
    Thank you!

    Hope this helps!

    Best regards,
    Andy

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