I have a loop pulling in two different custom post types. I have that loop showing the thumbnails of posts. Each post type used to have its own seperate loop and I had set up some png overlays to sit on top of the thumbnails. I had a play button icon over the thumbnails of the posts in the Video post type, and a stack of pictures icon over the slideshows post type thumbs. Now that I have combined the two loops I need a conditional statement to determine the post type and apply the appropriate overlay.
Here is the code I have that puts the play button over every thumb. How do I change this to a conditional that would apply the btn-play.png over video thumbs and <img src="<?php bloginfo('template_directory'); ?>/images/btn-ss.png" class="play" />
over slideshow thumbs?
<?php $new = new WP_Query(array ('post_type' => array('video', 'slideshow'), 'posts_per_page' => '5')); ?>
<?php while ($new->have_posts()) : $new->the_post(); ?>
<!-- BEGIN .post-container -->
<div class="post-container">
<div class="post-thumb"> <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'framework'), get_the_title()); ?>">
<?php if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { /* if post has post thumbnail */ ?>
<?php the_post_thumbnail('thumbnail-ws'); ?>
<?php }
else { ?>
<?php get_the_image( array( 'custom_key' => array( 'Thumbnail' ), 'width' => 100 ) ); ?>
<?php }
?>
<img src="<?php bloginfo('template_directory'); ?>/images/btn-play.png" class="play" /><span>
<?php the_title('<h2>', '</h2>'); ?>
<?php the_excerpt(); ?>
</span> </a> </div>
</div>
<?php endwhile; ?>
Any help incorporating this conditional statement would be greatly appreciated.
Just in case anyone is wondering about my code, which probably isn’t optimal: I have two tiers of thumbnails so all the old posts where I hadn’t specified a Thumbnail will use Justin Tadlock’s “get the image script”. Also, the weird setup with the span tags is because I have the title and excerpt show on mouseover (with css, no js).
You can do:
Then render the button with:
Hope that helps!