I am currently editing a wordpress theme with custom field outputs.
I have successfully made all the edits and everything works as it should.
My problem is that if a url is submitted into the custom field, the echo is exactly what was in there, so if someone enters www.somesite.com the echo is just that and adds it to the end of the domain: www.mysite.com www.somesite.com .
I want to check to see if the supplied link has the http://
prefix at the beginning, if it has then do bothing, but if not echo out http://
before the url.
I hope i have explained my problem as good as i can.
$custom = get_post_meta($post->ID, 'custom_field', true);
<?php if ( get_post_meta($post->ID, 'custom_field', true) ) : ?>
<a href="<?php echo $custom ?>"> <img src="<?php echo bloginfo('template_url');?>/lib/images/social/image.png"/></a>
<?php endif; ?>
substr
even if you can't figure out how to do this withRegEx
,strncmp
, or any of the many other methods....