alternating post styles

WP Alternating post styles

Thursday, November 19th, 2009

Many times i have looked for a simple solution to alternate the background colors on my wordpress post listings. Here is a simple solution to get the job done.
1) Create a variable and set it to 0 before the post’s while statement

<?php
$alternate = 0;
while (have_posts()) : the_post();
?>

2) Then with in the while statement create [...]