Hi Guys
I’m trying to get links in my masonry gallery to open in a new window.
I found this code in a previous topic (#281007) and tried adding it to the very end of my functions.php in the appearance editor.
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’);
Links still open in the same window though. Should I maybe add the code at another location in functions.php?
Hi graphicsplus!
Thank you for using Enfold.
Please try this:
function add_custom_script(){
?>
<script>
jQuery('.av-masonry-entry').each(function() {
jQuery(this).attr('target', '_blank');
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');
Regards,
Ismael
Hi Ismael,
I’ve added your code to the very end of my functions.php (outside the last brackets) using the appearance editor. But the links still open in the same window…
Hey!
Do you mind creating a temporary admin login and posting it here privately so we can look into it?
Best regards,
Yigit
Of course, be my guest!
It concerns the 5 sponsor logo’s at the very bottom of the homepage, just above the footer.
Hi Yigit,
Thanks! That worked great. I see I put the code in the wrong file. I put it in functions-enfold.php instead of theme functions.