I’ve come up with a solution (I think) but I’m really unsure if this is the way forward… I’m getting some strange behaviour from this when I change the count so it’s most likely wrong.
As I said, I was after something like this (no content here, just an image link), I’m pulling the forst image from each post and displaying it, and in after every 4th post I would like to add a div called “thumbs”
Post 1 Image 1
Post 2 Image 2
Post 3 Image 3
Post 4 Image 4
</div><div thumbs>
Post 5 Image 5
Post 6 Image 6
Post 7 Image 7
Post 8 Image 8
</div><div thumbs>
post 9 etc etc…
This is what kinda works… anyone see what I’ve done wrong?
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count%4== 0) : ?>
//this is for the after 4th, 8th, 12 etc posts
</div><div class="thumbs">
//end this is for the after 4th, 8th, 12 etc posts
<?php $postimageurl = get_post_meta($post->ID, 'thumbnail', true);
if ($postimageurl) {
?><div class="thumb">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", true); ?>
&w=300&zc=1" alt="" /></a>
<div class="vote">
<a href="/login" class="like"></a>
</div>
<a class="source" href="<?php the_permalink() ?>" target="_blank">Visit the source</a>
</div>
<?php } else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/wpshoutlogo.jpg" alt="WPShout.com | No image available" /></a>
<div class="vote">
<a href="/login" class="like"></a>
</div>
<a class="source" href="<?php the_permalink() ?>" target="_blank">Visit the source</a>
</div>
<?php } ?>
<?php else : ?>
<?php $postimageurl = get_post_meta($post->ID, 'thumbnail', true);
if ($postimageurl) {
?><div class="thumb">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumbnail", true); ?>
&w=300&zc=1" alt="" /></a>
<div class="vote">
<a href="/login" class="like"></a>
</div>
<a class="source" href="<?php the_permalink() ?>" target="_blank">Visit the source</a>
</div>
<?php } else { ?>
<img src="<?php bloginfo('template_directory'); ?>/images/wpshoutlogo.jpg" alt="" /></a>
</div>
<?php } ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>