I am editing the archive template so that when an archive is viewed from a custom taxonomy called "organisation" the template takes a url from the description field of that organisation and converts it into a link. i.e. if the organisation viewed is RandomCo then at the head of the archive page there would be a link to their website.
The only data in RandomCo's description is the url. I intend to add a custom field to the taxonomy, but wanted to get the template working using the description field first.
The variable picks up the url and echos it perfectly, but the link returns nonsense, beginning with the address to the organisation's archive page on my site.
I've tried a range of echo/ href combinations (see the code) but all return the same result.
<?php
$orgdesc = get_the_archive_description();
// I've tried these 4 approaches
echo "<a href='".$orgdesc."'>Link</a>";
echo "<a href='$orgdesc'>Link</a>";
$url = $orgdesc;
$link = '<a href="'.$url.'" target="_blank">Link</a>';
echo $link;
?>
<a href="<?php echo $orgdesc;?>"> Link </a>
The links from all the efforts above return the same value: http://example.com/organisation/randomco/%3Cp%3Ehttps://randomco.com/%3C/p%3E
https://randomco.com
` is not a valid URL. – gre_gor Sep 17 '19 at 23:08