modifying every other element’s class inside while loop
<?php $homePosts = new WP_Query(array( ‘posts_per_page’ => 5 )); $count = 1; while ($homePosts->have_posts()) { $homePosts->the_post(); if ( $count % 2 == 0 ) { $class=”right”; } else { $class=”left”; } ?> <section class=”align-<?php echo $class; ?>” > <div class=”content”> <?php the_title(); ?> <?php the_content(); ?> </div> </section> <?php $count++; } wp_reset_postdata(); ?> You can … Read more