• How do I use custom fields currectly?

    I’m using this now:

    <?php $flickr = get_post_meta($post->ID, 'flickr', true); ?>
    <?php $exif = get_post_meta($post->ID, 'exif', true); ?>
    <a href="<?php echo $flickr; ?>">View Flickr Page</a> | <a href="<?php echo $exif; ?>">View EXIF Data</a><br />

    How can I get the two links to only show if the custom field is filled in?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This will only show each one that is filled in. It will show the separator only if both are there. I didn’t test this actual code but this is how I do stuff like this.

    <?php $flickr = get_post_meta($post->ID, 'flickr', true); ?>
    <?php $exif = get_post_meta($post->ID, 'exif', true); ?>
    
    <?php if($flickr !=""){?>
    <a href="<?php echo $flickr; ?>">View Flickr Page</a>
    <?php } ?>
    <?php if($flickr !="" && $exif !=""){?>|<?php } ?>
    <?php if($exif !=""){?>
    <a href="<?php echo $exif; ?>">View EXIF Data</a>
    <?php } ?>
    <br />

    Thread Starter Ashkir

    (@ashkir)

    Thank you dralezero! It worked! :]

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Fields’ is closed to new replies.