Title: If/Else Custom Field (Adding style)
Last modified: August 19, 2016

---

# If/Else Custom Field (Adding style)

 *  Resolved [do77](https://wordpress.org/support/users/do77/)
 * (@do77)
 * [15 years ago](https://wordpress.org/support/topic/ifelse-custom-field-adding-style/)
 * Hi,
 * I want to display the content of a custom field on a single page only when the
   custom field was actually filled out. I know how to pull a custom field’s value
   into the template and add CSS style to it.
 * However, using the if/else statement the value including css style should only
   show up “if” the custom field was filled out. Right now the value shows up after
   the div containers but I kind of struggle to make it show up in the right place.
 * Its probably pretty basic php stuff but I still can’t make it work!
 * So here is my latest attempt:
 *     ```
       <?php
       $skills_values = get_post_meta($post->ID, 'skills', true);
       if ($skills_values){
       echo '<div class="listing-info-left">
       <h2>Required Skills</h2>
       <div class="inner-listing">
       </div>
       </div>' .$skills_values;
       }
       else {
   
       echo ' ';
       }
       ?>
       ```
   
 * I would appreciate some help with that!
 * Many thanks,
    do77

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years ago](https://wordpress.org/support/topic/ifelse-custom-field-adding-style/#post-2040970)
 * this might work:
 *     ```
       <?php
       $skills_values = get_post_meta($post->ID, 'skills', true);
       if ($skills_values){
       echo '<div class="listing-info-left">
       <h2>Required Skills</h2>
       <div class="inner-listing">'
       .$skills_values
       .'</div>
       </div>';
       }
       else {
   
       echo ' ';
       }
       ?>
       ```
   
 *  Thread Starter [do77](https://wordpress.org/support/users/do77/)
 * (@do77)
 * [15 years ago](https://wordpress.org/support/topic/ifelse-custom-field-adding-style/#post-2040974)
 * Yep, that did work. Thanks so much **again**!!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘If/Else Custom Field (Adding style)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [do77](https://wordpress.org/support/users/do77/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/ifelse-custom-field-adding-style/#post-2040974)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
