Be Studios

Intercontinental Design Firm

This is our knowledge center. Enjoy!

Alternate classes (even-odd) in posts within loop in WordPress

<?php $the_query = new WP_Query(); function cycle(&$arr) { $arr[] = array_shift($arr); return end($arr); } $oddEven = array('even', 'odd'); ?>

<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
[the post info]
<?php endwhile; ?>