Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #744781

    I found the following code and it does the job

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

    It does it a little to well though. That causes all masonry elements site wide to open in new window.
    Would it be possible to target a certain page rather than site wide? Maybe through page-id?

    Many Thanks

    Tim

    #744811

    Hey tjswarbs78,

    Yes it is possible to target certain pages

    Edit the below line and add the page id before .av-masonry-container

    jQuery('.av-masonry-container a ').attr('target','_blank');
    

    It should look like

    jQuery('.page-id-xx .av-masonry-container a ').attr('target','_blank');
    

    Best regards,
    Vinay

    #744830

    OMG i can’t believe i didn’t think of that!

    Thanks

    TJ

    • This reply was modified 7 years, 9 months ago by tjswarbs78.
Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Open masonry items in new window’ is closed to new replies.