Add class every 4 post like , class_1, class_2, class_3, class_4 and class_1, class_2, class_3, class_4


Hey guys im trying to add a class every 4 post in wordpress loop like in the image above

enter image description here

im using the simple loop of wordpress, I have investigated about using a counter or modulo but have not found a solution, can you guys help me, Thanks.

 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<div class="col-md-3">

    <div class="box_ow">
            <div class="rollover_cont" style="background-color: #098EAD; mix-blend-mode: multiply; z-index:1;">
            <h3> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h3>
            <a class="go_project_link" href="<?php the_permalink(); ?>">Go to Project ></a>
            <img class="img-fluid icons_social_img" src="<?php bloginfo('template_directory') ?>/assets/images/icons_social.svg" alt="">


            <img class="img-fluid" src="<?php bloginfo('template_directory') ?>/assets/images/image_holder.jpg" alt="">


<?php endwhile; else : ?>
    <p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
kelvin ramirez 2 months 0 Answers 6 views 0

Leave an answer