I am looking for the correct why to right this code. The code I have shows up with my website address in front and I just need this to be a _blank target link to open! Shows up like this: http://www.mysite.com/folder/folder/page/http://www.linkineed.com Just need: http://www.linkineed.com Thanks, Adam <?php if($link != '') : ?> <li class="link clear"> <button class="button"><a target="_blank" href="<?php echo $link; ?>"><?php _e('Download File', 'author'); ?></a></button> </li> <?php endif; ?> Code (markup):
Well, I would guess that the contents of the $link would be the website page directory and than the "<?php _e('Download File', 'author'); ?>" would be the text field in the post editor that I write, but I am not 100% sure about that.
Well, I found this code on the same page, does this help? <?php $caption = get_post_meta(get_the_ID(), 'portfolio_caption', TRUE); $link = get_post_meta(get_the_ID(), 'portfolio_link', TRUE); ?> Code (markup):
yes, but not if we don't know the content (use print_r($caption) or print_r($link) to display the results) but i think if you remove the $link part you'll get the correct writen domain name!
Change the code to <?php if($link != '') : ?> <li class="link clear"> <button class="button"><a target="_blank" href="<?php echo $link; ?>"><?php _e('Download File', 'author'); ?></a></button> </li> <?php endif; echo '<br />'.$link; exit; ?> PHP: Then you can see what the link is. If it's not http://www.linkineed.com follow get_post_meta(get_the_ID(), 'portfolio_link', TRUE); back to see where it's being set to what you don't want.
You'll probably need basename(), or some fancy Regex. It all depends on what you have. Also, I believe Rukbat's code could be changed from if($link != '') to if($link) and echo '<br />'.$link;exit; to exit('<br />'.$link);