I need some coding help here. I want to capture a custom field and using an "if not null statement echo output in a link form". Here's what I thought would work but does not:
<?php if ( $wpcm_number_facebook != '' ) { echo '<li><span class="number">'<a href=\"' . $wpcm_number_facebook. '\" /> (facebook) </a>' </li>'; } ?>
<?php
// $fieldnm is null if the custom field doesn't exist
$fieldnm = get_post_meta($post->ID,'yourfieldname',true);
// If the field exists
if($fieldnm) { ?> YOURHTMLHERE <?php }
// Field is null (doesn't exist)
else { ?> SOMEOTHERHTML <?php }
?>
Or using echo..
<?php
// $fieldnm is null if the custom field doesn't exist
$fieldnm = get_post_meta($post->ID,'yourfieldname',true);
// If the field exists
if($fieldnm) { echo 'something to echo'; }
// Field is null (doesn't exist) // Remove if not needed
else { echo 'the field is null'; }
?>
Hope that helps...
Update 'yourfieldname' with your actual custom field name.