Default Thumbnail Image
-
I currently have my archive set to do something like this: if post has featured image, use that, if not, use the first image from the post. This is working fine. However, I want to take it a step further and say if no image in post, use a default image. This way ill be able to use featured images if needed, if not grab the first image, and if no image has been used, use a default image. Here is my current html and logic that is working.
<div class="post-thumb"> <a href="<?php the_permalink(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { echo PostThumbURL(); } else { echo main_image(); } ?>&w=200&h=200&zc=1" alt="image" class="frame" /></a> </div>
I have tried a few things. It seems like I need to get this code into the logic somehow but im not great with php just yet.
<?php if ( has_post_thumbnail() ) { the_post_thumbnail(); } else { ?> <img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" alt="<?php the_title(); ?>" /> <?php } ?>
Thanks for any help.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Default Thumbnail Image’ is closed to new replies.