Corentin Branquet Corentin Branquet - 1 month ago 4
PHP Question

remove site url from links Wordpress

I have to display link into my website like this :

$url = 'google.com';
<a href="<?php echo $url; ?>">Check it !</a>


What I don't understand now is that, the output href is not
google.com
but
mydomain.com/google.com
.

I don't know how to resolve this issue.

Answer

You need to append http:// before your url

Try below code:

 $url = 'http://www.google.com';
   <a href="<?php echo $url; ?>">Check it !</a>