-
AuthorPosts
-
February 22, 2017 at 4:31 pm #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 }
February 22, 2017 at 6:18 pm #750579Hey 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- This reply was modified 7 years, 10 months ago by Jordan Shannon.
February 22, 2017 at 9:04 pm #750662Hi,
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.February 22, 2017 at 9:21 pm #750674Hi!
Can you please add private details with backend access so we can review the code please?
Thank youBest regards,
BasilisFebruary 23, 2017 at 2:27 pm #750931Hey,
here it is.February 28, 2017 at 1:04 pm #752903Hi,
Sorry for the late reply!
I added following code to custom functions sectionfunction 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,
YigitFebruary 28, 2017 at 4:48 pm #753044Hey,
results are the same. Loaded posts open in the same window. :)March 5, 2017 at 3:20 pm #755936Hi,
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,
NikkoMarch 7, 2017 at 11:11 am #756890Hello,
allright, thank you.
March 13, 2017 at 8:21 am #759861Hi!
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,
IsmaelMarch 13, 2017 at 9:39 am #759886Hello,
Perfect. Thank you kriesi team :)March 13, 2017 at 10:46 am #759906 -
AuthorPosts
- The topic ‘Open massonry elements in new window’ is closed to new replies.