How to change the link ?

Discussion in 'HTML & Website Design' started by mike4uuu, Aug 16, 2010.

  1. #1
    I m having a weird problem,

    I'm trying to insert a link retrieved from custom field "urladd" ( I'm using Wordpress as cms )

    <a href="<?php echo get_post_meta($post->ID, 'urladd', true); ?> " target="_blank"> My link</a>

    But the link shows the post url and than the link i m trying to extract !

    Its like this :

    http://www.abc.com/mypost/customfieldlink

    Instead of this how can i show just the custom field link

    http://[B]customfieldlink[/B]

    Please somebody help me ! Thanks !
     
    mike4uuu, Aug 16, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you have http:// in front of the custom links?

    If not, try <a href="http://<?php echo get_post_meta($post->ID, 'urladd', true); ?> " target="_blank"> My link</a>
     
    Cash Nebula, Aug 16, 2010 IP
  3. mike4uuu

    mike4uuu Active Member

    Messages:
    832
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I dont have but when i insert , it shows - http:///

    It works perfectly when i change it to

    <a href="http://www.abc.com " target="_blank"> My link</a>

    Also <?php echo get_post_meta($post->ID, 'urladd', true); ?> shows the link as www.abc.com

    oh. i forgot to mention that i m working on xampp a localserver on my pc.
     
    mike4uuu, Aug 16, 2010 IP
  4. mike4uuu

    mike4uuu Active Member

    Messages:
    832
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Its working now thanks NEBULA !
     
    mike4uuu, Aug 16, 2010 IP
  5. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Great! :cool:

    This is a little better because the link only appears when there is something in the field:
    <?php if( get_post_meta($post->ID, 'urladd', true) ) :?>
    <a href="http://<?php echo get_post_meta($post->ID, 'urladd', true); ?> " target="_blank"> My link</a>
    <?php endif;?>
    
    Code (markup):
     
    Cash Nebula, Aug 17, 2010 IP