I’m currently building a new homepage: http://designplanung-leipzig.de/projekt-003/trainingsgruppen/
You will see two galleries there. The first should (as now) not open a new browser window on click, the second should. So when you click on a logo, a new window with the link should open. How could that be solved? First I installed this code here, but then a new window opens in the upper gallery and I don’t want that:
function new_custom_script () {
?>
<script>
(function ($) {
$ (document) .ready (function () {
$ (‘. av-masonry-entry’). each (function () {
$ (this) .attr (‘target’, ‘_blank’);
});
});
}) (jQuery);
</script>
<? php
}
add_action (‘wp_footer’, ‘new_custom_script’);
Best regards,
Martin
Hi Martin,
Please try to use this code and put it at the bottom of functions.php of your child theme:
function masonry_links () {
?>
<script>
(function ($) {
$(document).ready (function () {
var url = new RegExp(location.host);
$('.av-masonry-entry').each(function () {
if( ! url.test($(this).attr('href')) ) {
$(this).attr('target', '_blank');
}
});
});
}) (jQuery);
</script>
<?php
}
add_action ('wp_footer', 'masonry_links');
This code works on Masonry Galleries, if it’s an external link it will open in new tab.
Hope this helps :)
Best regards,
Nikko
Coooooool – thank you very much Nikko!!!
Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon
Close please
Hi m_reiprich,
Thanks for using Enfold and have a great day :)
Best regards,
Nikko