Tagged: custom link, Masonry Gallery, target blank
Hi, quick question:
Is there a quick CSS I can use to open the Masonry Gallery Custom Link in a new Tab/Window ?
Many thanks,
H
Hey Heathcliffe,
There is no CSS to do that, but u can do it with some Jquery.
You can use the following, by changing the id with the mansory ID
$(‘a#link_id’).click(function() {
$(this).attr(‘target’, ‘_blank’);
});
let us know if that helps you out
Best regards,
Basilis
Many thanks for the quick reply and the solution. I’m not a coder. Where do I add this code?
Thanks,
H
Hi,
Sorry for the delay. You can add the code in the functions.php file:
// new script
add_action('wp_footer', 'ava_new_custom_script_masonry');
function ava_new_custom_script_masonry(){
?>
<script type="text/javascript">
(function($) {
function e() {
$('.av-masonry-gallery').each(function() {
$(this).find('.av-masonry-entry').attr('target', '_blank');
});
}
e();
})(jQuery);
</script>
<?php
}
Best regards,
Ismael
Thanks guys,
I managed to create a child theme and put this in functions.php and it works fine.
Much appreciated.
Hello,
I also want my Masonry Gallery to be able to open a new window. I have pasted the code in Function.php but nothing changes. The current environment page is: http://www.designplanung.com/projekt-068/
Do I have to change the page as a child theme? What could be the problem? I use the latest WordPress and Enfold 4.7.4.
Best regards,
Martin
Hi Martin,
There are errors in your JavaScript.
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
Victoria
Hello Victoria,
how do i do it again?