Reputation: 47
I want to redirect to another page or website in WordPress. I am using below code In which $page variable contains the URL of the website and want to redirect it with a tag href. Problem is the link is appended to localhost current page URL.
the code is here
$page= get_post_custom_values('projPage');
if($page[0] != ""){
var_dump($page);?>
<p>
<a href="<?php echo $page[0];?>">Project Page</a>
</p> <?php
} else { ?>
<p><em>Project Page Unavailable</em></p><?php
}
Upvotes: 0
Views: 47
Reputation: 7080
Your URL should have a protocol like HTTP or HTTPS else it is considered as a relative path.
$page[0]= 'http://www.google.com';
if($page[0] != ""){
var_dump($page);?>
<p>
<a href="<?php echo $page[0];?>">Project Page</a>
</p> <?php
} else { ?>
<p><em>Project Page Unavailable</em></p><?php
}
this one is works fine for me
Upvotes: 1