Conditional custom fields WordPress
Sometimes we need to implement some custom field values with a condition. Example, if i need to show an image in the index page and all post does not an image, then we can use the conditional custom fields.
Here is the code:
<?php
$myimage = get_post_meta($post->ID, ‘image’, true);
if ($myimage == ‘ ‘)
{ ?>
<?php the_excerpt(); ?>
<?php } else { ?>
<a href=”<?php the_permalink(); ?>”><img src=”<?php echo $myimage; ?>” class=”alignleft” /></a>
<?php the_excerpt(); ?>
<?php } ?>
Enjoy


