Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #750541

    Hello,
    these codes work. However, posts loaded after pressing “load more” button open in the same window.

    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');

    or

    add_filter('wp_footer', 'avf_add_target_blank', 10);
    function avf_add_target_blank() { ?>
    <script>
    (function($){
        $(window).load(function() {
        	$( ".av-masonry-container a" ).each(function() {
    			$(this).attr('target','_blank');  
    		});
        });
    	
    })(jQuery);
    </script>
    <?php
    }
    #750579

    Hey demarko19,

    Where are you adding the code? 

    Switch to the Text editor and add this to the bottom.

    <script type = “text/javascript”>
    jQuery(‘.av-masonry-container a’).attr(‘target’, ‘_blank’);
    </script>

    If your using the Masonry Gallery then that will have the custom links open in a new window.

    Best regards,
    Jordan Shannon

    #750662

    Hi,
    used in functions.php.
    Tried your solution, same results. First posts open in new tab, but those loaded with load more ajax button open in the same tab.

    #750674

    Hi!

    Can you please add private details with backend access so we can review the code please?
    Thank you

    Best regards,
    Basilis

    #750931

    Hey,
    here it is.

    #752903

    Hi,

    Sorry for the late reply!
    I added following code to custom functions section

    function av_custom_link_target(){
    ?>
     <script>
    jQuery(window).load(function(){
    jQuery('.home #av-masonry-1 a.av-masonry-entry').attr('target','_blank');
    });
     </script>
    <?php
    }
    add_action('wp_footer', 'av_custom_link_target');

    Best regards,
    Yigit

    #753044

    Hey,
    results are the same. Loaded posts open in the same window. :)

    #755936

    Hi,

    The code Yigit gave works however when the additional masonry items are loaded it doesn’t run the code again, I tried to add a code to trigger when button is clicked but it doesn’t work also, will try to help you on this but will need more time though.

    Best regards,
    Nikko

    #756890

    Hello,

    allright, thank you.

    #759861

    Hi!

    Please replace the script with the following.

    function ava_custom_script(){
    ?>
    <script>
    (function($){
    	function a1() {
    		$(window).on('av-height-change', function(e) {
    			$('.av-masonry-container a').attr('target','_blank');
    		});
    	}
    
    	a1();
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_custom_script');

    Best regards,
    Ismael

    #759886

    Hello,
    Perfect. Thank you kriesi team :)

    #759906

    Hey!

    Glad we could help. Please feel free to open a new thread if you need anything else. :)

    Cheers!
    Ismael

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Open massonry elements in new window’ is closed to new replies.