You could try putting in a counting variable that you increment with every pass, and then inside, you have if statement to see if it’s every other or not… something like this…
<?php $i = 1; ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if($i%2 == 0) : ?>
This thread gave me an idea. If you’ve ever used Smarty templates, loops have certain variables automatically set for index (zero-based), iteration (1 based), even, odd, first, and last. These are very useful or setting classes, changing styles, alternating colors, etc. It just occurred to me that Wordpress could easily have this functionality within The Loop by wrapping have_posts() in a custom function:
function super_have_posts() {
global $first, $last, $index, $iteration, $even, $odd;
...calculate all your variables here, account for multiple loops, etc...
if(have_posts()) {
return true;
}
}
then you would just use while(super_have_posts()) in your loop. What do you guys think?