Reputation: 89
Is this correct? Basically I want to open a link in new tab if the link type is external. Otherwise don't open it in new tab if the link type is embed.
I have two link types:
The following code doesn't open the external link_type in new tab
<a id="sample" href="sample.com">This is a link <?php if($t_link->link_type == 'External') echo target="_blank href="sample.com"; ?> </a>
Upvotes: 3
Views: 1544
Reputation: 89
I found a fix, This is now my code and it work perfectly:
<a target="_blank" href="<?=get_option('url') ?>/wpwm-redirect?link_id=<?=$t_link->linkID ?>"<?php if($t_link->link_type == 'Embed') echo ' id="default-video" onclick="ayeLoadVideo(\'/wpwm-redirect?link_id=' . $t_link->linkID . '\'); return false;"'; ?>> <?=$t_link->link_title ?> </a>
Upvotes: 0
Reputation: 434
switch($t_link->link_type){
case "External":
echo "<a id='sample' href='sample.com' target='_blank'></a>";
break;
case "Embed":
echo "<a id='sample' href='sample.com' ></a>";
break;
}
Upvotes: 2
Reputation: 12391
<?php if($t_link->link_type == 'External')
echo "<a target='_blank' href='http://www.sample.com'> This is an external link</a>";
else
echo "<a href='sample.com'> This is an internal link</a>";
?>
Upvotes: 3