July 07, 2015
Drop the below if statement within a loop and add a count for each colour change that you need with the template.
This is a great example to reference if you’re building a scrolling website, and loading all pages in a single progression with alternating templates applied.
<li class="training_content <?php ++$count; if($count % 5 == 1) { echo "one"; } else if($count % 5 == 2) { echo "two"; } else if($count % 5 == 3) { echo "three"; } else if($count % 5 == 4) { echo "four"; } else { echo "five"; } ?>"> <h2><?php the_title(); ?></h2> <h3><?php echo $subtitle; ?></h3> <?php the_content(); ?> </li>
Sourced here.