There is a conclusion of posts

<div class="row"> <?php $args = array( ); ?> <?php $my_posts = get_posts('numberposts=200&category=6'); $countCategory = get_category(6)->category_count; foreach ($my_posts as $post) : setup_postdata($post); ?> <div class="col-md-3 oneBlogBlock green"> <a class="" href="<?php the_permalink(); ?>"> <h3> <?php trim_title_chars(30, '...'); ?> </h3> <p> <?php $text = get_the_content(); echo wp_trim_words( $text, 25, ' ...' );?> </p> </a> </div> <?php endforeach; ?> </div> 

The blog has 200 entries. The first record must be in one block, the second, third, fourth and fifth must be in other blocks, and such a cycle must be looped. I want to write a slider, and in one slide there will be 5 records each, but I cannot break it.

Help me please!

    1 answer 1

     $i = 0; foreach ($my_posts as $post) : setup_postdata($post); $i++; if($i == 1) { <div class="oneBlogBlock"> ... }elseif($i > 1 && $1 < 6) { <div class="twoBlogBlock"> ... }else { $i = 0; } endforeach; 
    • God bless you and full of pockets bablyshka! Thank you - Archi Savin
    • no, well, from the heart)) - Kirill Korushkin