Using the new “the_post_thumbnail” function. Within The Loop, I want to display post thumbnails for all my posts. Here’s what I’m doing:
<div class="entry"> <div class="post_thumb"> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a> </div> <?php the_excerpt(); ?> </div>
Works, great! Love it.
But, I ONLY want the div containing the thumbnail (<div class=”post_thumb”>) to show up if there’s a thumbnail. Otherwise, there’s just an empty div showing up on posts that have not been assigned a post thumbnail. I’m not an expert at php but I’m learning, and I know there’s some sort of “conditional” statement I can create to achieve this, Like, “if function exists the_post_thumbnail…”?
Any php experts out there to throw a quick hand?
- The topic ‘How Do I Display a div, ONLY if the post has a post_thumbnail?’ is closed to new replies.