Skip to content

Instantly share code, notes, and snippets.

@ms-studio
Created August 10, 2012 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ms-studio/3313103 to your computer and use it in GitHub Desktop.
Save ms-studio/3313103 to your computer and use it in GitHub Desktop.
Output WP custom field as list
<?php
$weblinks = get_post_meta($post->ID, 'Web-Link', false);
// false = will return an array of results
if ($weblinks) {
?>
<div class="hyperlinks">
<?php
foreach($weblinks as $weblink) {
// test if it starts with HTTP ....
// and remove it
$cleanlink = str_replace("http://", "", $weblink);
echo '<div class="link"><a href="http://'.$cleanlink.'" target="_blank">'.$cleanlink.'</a></div>';
} ?>
</div><!-- .hyperlinks -->
<?php }
// end if;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment