• Resolved surfershort

    (@surfershort)


    Hi on my website pages festivalnet.co.uk here

    I have some custom fields that are populated by a user upload form one of the custom fields should display their website in the template using the below code but for some strange reason it adds my domain before it like this

    http://festivalnet.co.uk/seed-staff/www.seedstaff.com

    Instead of this

    http://www.seedstaff.com

    This is my template code

    <ul>
    		<?php if(get_post_meta($post->ID, 'email_contact', true)): ?>
    		<li><a href="mailto:<?php echo get_post_meta($post->ID, 'email_contact', true); ?>">Contact Us</a></li>
    		<?php endif; ?>
    
    		<?php if(get_post_meta($post->ID, 'website', true)): ?>
    		<li><a href="<?php echo get_post_meta($post->ID, 'website', true); ?>">Our Website</a></li>
    		<?php endif; ?>
    
    		<?php if(get_post_meta($post->ID, 'telephone_contact', true)): ?>
    		<li><?php echo get_post_meta($post->ID, 'telephone_contact', true); ?></li>
    		<?php endif; ?>
    	</ul>

    Can anyone see what is causing this…?

    Many Thanks
    Al

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think you need to make sure it is formatted correctly, starting ‘http:’, same format for the ‘mailto:’ or test for ‘@’ just in case!

    <?php if(get_post_meta($post->ID, 'website', true)): ?>
    <?php
    	$website = get_post_meta($post->ID, 'website', true);
    	$pos = strpos($website,'http:');
    	/* 0=first characters so use !== */
    	$url=( $pos !== false ) ? $website : 'http:' .$website;
    ?>
    	<li><a href="<?php echo $url; ?>">Our Website</a></li>
    <?php endif; ?>

    HTH

    David

    Thread Starter surfershort

    (@surfershort)

    Thankyou David – Perfect

    No problem, please mark it as resolved!

    David

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Strange Custom field….’ is closed to new replies.