If No Featured Image
-
Hi all,
I’m using the theme “Shuttershot”. When I make a blog post, but I don’t set a featured image, it just shows a blank image.
I realise this is because it’s using fall back/default image instead. What I’d like to do is have it so that if there’s no featured image uploaded, it doesn’t show an image.The code I’m working with is:
<div class="entry"> <?php if ( has_post_thumbnail() ) { ?> <a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=200&w=470&zc=1" alt=""/></a> <?php } else { ?> <a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a> <?php } ?> <?php the_excerpt(); ?> <div class="clear"></div> </div>I’ve had a look at the documentation, but it didn’t seem to help. Unfortunately, my knowledge of PHP is seriously lacking.
I initially thought that if I just removed the “else” code, then it would work, but it didn’t appear to. Unless I didn’t remove enough/the right bit?
Anyway, hopefully that makes sense.
Thanks in advance,
Will.
The topic ‘If No Featured Image’ is closed to new replies.