Alternate wordpress post ACF (nth child)

I am trying to insert 4 different classes in accordance to the design aspect.

e.g.

ROW 1: [IMAGE 1, GREEN, LEFT] | [IMAGE 1, GREEN, LEFT] | [IMAGE 1, GREEN, RIGHT] [IMAGE 1, GREEN, RIGHT]

ROW 2: [IMAGE 1, RED, LEFT] | [IMAGE 1, RED, LEFT] | [IMAGE 1, RED, RIGHT] [IMAGE 1, RED, RIGHT]

ROW 3: [IMAGE 1, GREEN, LEFT] | [IMAGE 1, GREEN, LEFT] | [IMAGE 1, GREEN, RIGHT] [IMAGE 1, GREEN, RIGHT]

ROW 4: [IMAGE 1, RED, LEFT] | [IMAGE 1, RED, LEFT] | [IMAGE 1, RED, RIGHT] [IMAGE 1, RED, RIGHT]

How would i go about doing this?

This is what i was thinking, declaring a class variable in the beginning of the header

<?php 
        $oddpost = 'alt';
?>

Simple echo out that alt post as a class on the wordpress itself.

THen:

<?php 
if ('alt' == $odd) $odd = '';
else $odd = 'alt';
?>

Thanks again for your help.

p.s. here is the ACF code (working fine, ripping testimonials)

                <?php
                        $args = array( 'post_type' => 'testimonials', 'posts_per_page' => 16 );
                            $loop = new WP_Query( $args );
                            while ( $loop->have_posts() ) : $loop->the_post();
                                echo '<div class="one_fourth"><div class="testimonial"><blockquote><p>';
                                the_field('testimonial');
                                echo '</p></blockquote><p><cite>';
                                the_title();
                                echo '</cite></p></div></div>';
                            endwhile;
                    ?>

Read more here: Alternate wordpress post ACF (nth child)

Leave a Reply

Your email address will not be published. Required fields are marked *