Custom field value to URL
-
Hello folks!
I created custom field named “productlink”, and i am showing it on my homepage using this piece of code, and it works great:
<?php $field_name="productlink"; $field_value = get_post_meta($post->ID, $field_name, true); ?> <a href="<?php echo $field_value; ?>" class="readmore-button">BUY IT NOW</a>This piece of code shows the “Buy it now” link which works perfectly if the user enters link with http:// in the custom field.
If he just enters (for example) http://www.google.com, link on the homepage becomes http://www.mywebsite.com/www.google.com.I am not native english speaker, so i hope i explained it well.
Any help would be great!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Custom field value to URL’ is closed to new replies.