Title: Plugin WP Types &#8211; display default value if empty
Last modified: August 20, 2016

---

# Plugin WP Types – display default value if empty

 *  [Timmito](https://wordpress.org/support/users/timmito/)
 * (@timmito)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-types-display-default-value-if-empty/)
 * Hey there,
 * Just switched from magic fields to WP Types and to get things bulletproof I want
   to make sure if a field is empty, that there’s still some content being displayed.
   In my case it’s about defining an image…
 * The code I’ve previously been using to achieve this is:
    ` <?php $values = get_post_custom_values("
   fieldname"); if (isset($values[0])) { ?> <img src="<?php echo get('fieldname');?
   >" alt="<?php the_title(); ?>"/> <?php }
 *  else { ?>
    <img src=""/> <?php } ?>
 * Any idea how to achieve this with “types_render_field”? Can’t get it to work 
   with WP Types…
 * Thanks in advance!

Viewing 1 replies (of 1 total)

 *  [wiktoratgmail](https://wordpress.org/support/users/wiktoratgmail/)
 * (@wiktoratgmail)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wp-types-display-default-value-if-empty/#post-2701899)
 * This is working for me:
 *     ```
       <?php
       $url=(types_render_field("url", array("raw"=>"true")));
       if ($url== '')
       { ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
       <?php } else { ?>
       <a href="<?php echo (types_render_field("url", array("raw"=>"true"))); ?>" target="_blank" rel="bookmark" title="<?php the_title(); ?>">
       <?php } ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Plugin WP Types – display default value if empty’ is closed to new replies.

## Tags

 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [default](https://wordpress.org/support/topic-tag/default/)
 * [wp-types](https://wordpress.org/support/topic-tag/wp-types/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [wiktoratgmail](https://wordpress.org/support/users/wiktoratgmail/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wp-types-display-default-value-if-empty/#post-2701899)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
