Hi there!
I want to be able to set some Portoflio items custom link to open on a new tab. Looking around the Forum I found that the moderator Ismael recommended placing this code into functions.php
add_action('wp_footer', 'ava_grid_target');
function ava_grid_target(){
?>
<script>
(function($){
$(".grid-image").each(function() {
$(this).attr('target', '_blank');
});
})(jQuery);
</script>
<?php
}
1. Is it correct? I haven’t tried it because the person who requested it said that his site broke.
2. Can I choose which Portfolio items to open in a new tab and some in the same tab?
Thanks!!
Hey worldfuturecouncil!
Yes the code is correct as it seems.
You could make it per selection, if you an assign different classes / ids’ to that code and load the items based on that.
It can work, but it would require a lot of coding to be done.
Please let me know if you need anything else.
Cheers!
Basilis
HI Basilis, thanks for getting back to me.
I would only want to create two classes. One which opens the portfolio in a new tab and one where it opens in the same window.
How would I go about doing that?
Thanks!
Hi!
You can turn on custom CSS field for ALB elements – http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/ and then edit your element which you would like to open in new window and give it a custom class and then changed the code to following one
add_action('wp_footer', 'ava_grid_target');
function ava_grid_target(){
?>
<script>
(function($){
$(".your-custom-class .grid-image").each(function() {
$(this).attr('target', '_blank');
});
})(jQuery);
</script>
<?php
}
Best regards,
Yigit