Tagged: new window
Hello,
I saw a different post with a similar inquiry, tried implementing the code, and it didn’t work. So, I figured I’d ask the question.
I’m using two fullwidth masonry portfolio grids, and for one of them I’d like the portfolio item links to open in new windows. I tried changing out the code per this forum response: https://kriesi.at/support/topic/portfolio-custom-link-to-open-in-a-new-page/#post-223280; and it didn’t work.
Thank you for your help.
Hey GavinAnstey!
Open up wp-content/themes/enfold/config-templatebuilder/avia-shortcodes/masonry_entries.php and replace:
if($custom_link) $this->loop[$key]['url'] = $custom_link;
with
if($custom_link) $this->loop[$key]['url'] = $custom_link;
if($custom_link) $blank = "target='_blank'";
and
$this->loop[$key]['html_tags'] = array('a href="'.$this->loop[$key]['url'].'"','a');
with
if(empty($blank)) $blank = '';
$this->loop[$key]['html_tags'] = array('a '.$blank.' href="'.$this->loop[$key]['url'].'"','a');
Regards,
Peter
Hi Dude,
I follow your recomandations but the links still open on the same window.
Thanks
Hi!
Can you please post the link to your website and elaborate on the changes you would like to make?
Regards,
Yigit
Hi!
Please add following code to Functions.php file in Appearance > Editor
function add_custom_target(){
?>
<script>
jQuery(window).load(function(){
jQuery('#av-masonry-1 a').attr('target','_blank');
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_target');
Regards,
Yigit
Hi Yigit,
it seems to work perfectly with your function
And I have restored config-templatebuilder/avia-shortcodes/masonry_entries.php
I did well?
It still works fine.
Thanks