Alex
Alex

Reputation: 135

PHP open link in new tab

How to add target "blank" to a link in Wordpress "functions.php". The link which opens in same window is:

<a href=\"".$widj_options['link']."\" class=\"btn-bg btn-bg-widget w-button\">".$widj_options['title']."</a>

For some reason adding the target blank before the href doesn't work:

<a target = '_blank' href=\"".$widj_options['link']."\" class=\"btn-bg btn-bg-widget w-button\">".$widj_options['title']."</a>

Upvotes: 2

Views: 1029

Answers (4)

Su Yatanar
Su Yatanar

Reputation: 181

Try to add like that.

<a target ='_blank' href='<?=$widj_options['link']?>' class='btn-bg btn-bg-widget w-button'><?=$widj_options['title']?></a>

Upvotes: -1

Nimesh Patel
Nimesh Patel

Reputation: 804

Remove space target="_blank"

OR

You are doing it right, so we need to check for incompatibility issues. Please try with no extra plugins enabled (Only Toolset) and with a default WordPress theme.

Upvotes: 0

Muzaffar Mahmood
Muzaffar Mahmood

Reputation: 1908

Do something like this.

<a target='_blank' href='".$widj_options['link']." class='btn-bg btn-bg-widget w-button'>".$widj_options['title']."</a>

Upvotes: 1

rk_programmer
rk_programmer

Reputation: 78

please remove the space after target

<a target='_blank' href=\"".$widj_options['link']."\" class=\"btn-bg btn-bg-widget w-button\">".$widj_options['title']."</a>

Upvotes: 1

Related Questions