Hide article image if empty
-
Hey,
I use Custom Fields on my weblog to post a article image next to each post. Now on some posts I dón’t want a article image. But if I leave the custom field empty, it still displays the container of the image. I know it’s possible to hide the complete container if there is no content for it, but I don’t know how!
This is the code I use for article images:<?php //get article_image (custom field) ?><?php $image = get_post_meta($post->ID, 'article_image', true); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><div id="artimg_container"><img class="artimg" src="<?php echo $image; ?>" width="110" height="110" alt="<?php the_title(); ?>" align="right"/></div></a>
- The topic ‘Hide article image if empty’ is closed to new replies.