Hey Guys,

I am having an issue with my custom field for my download button within post loop. It is supposed go to an external link, but when I enter the "download_url" value it ends up linking to "www.mysite.com/blog/http://www.downloadurl.com" instead of "http://www.downloadurl.com". So basically it is adding my blog url before my custom field. How would I get just the value of my custom field?

Here is my code:

<a href="<?php if (get_post_meta($post->ID, 'download_url', true)) { ?><?php echo get_post_meta($post->ID, "download_url", $single = true); ?><?php } ?>"><span>Download</span></a>

Any help would be greatly appreciated! Thank you for your time : )

I think, you forgot to add http:// to your custom field value.

<?php
$downloadurl = get_post_meta($post->ID, 'download_url', true);
if($downloadurl != ""){
echo '<a href="'.$downloadurl.'"><span>Download</span></a>';
}
?>

It works fine :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.