Title: PHP help &#8212; Skip code if Custom Field has no value
Last modified: August 18, 2016

---

# PHP help — Skip code if Custom Field has no value

 *  [chudsf](https://wordpress.org/support/users/chudsf/)
 * (@chudsf)
 * [19 years, 2 months ago](https://wordpress.org/support/topic/php-help-skip-code-if-custom-field-has-no-value/)
 * Hello there. I’m using custom fields to display information about press clippings.
   I’ve got four — date, publication, PDF, and Link.
 * I have the template spit out a little PDF icon linking to the PDF version and
   the text “LINK” linking to the online version of a clipping.
 * This is working wonderfully, but some of my clippings do not have either a PDF
   version or a link, and these fields are empty. The template then generates an
   icon/link that links to nothing. How can I get this code to skip the custom field
   if it is empty?
 * My code:
 *     ```
       <?php if ( in_category('3') ): ?>
       <span class="caps" style="font-size: 8pt">
       >>Published <?php echo get_post_meta($post->ID, 'Date', true); ?> in <?php echo get_post_meta($post->ID, 'Publication', true); ?>.
       <a href="<?php echo get_post_meta($post->ID, 'PDF', true); ?>"><img src="/images/pdficon.gif" border="0"></a>
       <a href="<?php echo get_post_meta($post->ID, 'Link', true); ?>">LINK</a>
       <br><br>
       </span>
       <?php endif; ?>
       ```
   

The topic ‘PHP help — Skip code if Custom Field has no value’ is closed to new replies.

## Tags

 * [action](https://wordpress.org/support/topic-tag/action/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [field](https://wordpress.org/support/topic-tag/field/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [value](https://wordpress.org/support/topic-tag/value/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [chudsf](https://wordpress.org/support/users/chudsf/)
 * Last activity: [19 years, 2 months ago](https://wordpress.org/support/topic/php-help-skip-code-if-custom-field-has-no-value/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
