Help is needed to wrap all subsequent posts after the 3rd in the container "X".

Now the code is as follows:

<?php $sn_args = array( 'post_type' => 'post', 'paged' => $paged, 'cat' => '27,31,20', 'posts_per_page' => '11', ); ?> $querysn = new WP_Query( $sn_args ); if ( $querysn->have_posts() ){?> <?php while ( $querysn->have_posts() ) : $querysn->the_post() ; ?> <?php $c++; if( !$paged && $c == 1) :?> <?php include 'template-parts/content-news-first-fullheight.php'; ?> <?php elseif( !$paged && $c > 1 && $c <= 3) :?> <?php include 'template-parts/content-news-small-fullheight.php'; ?> <?php else:?> <?php include 'template-parts/content-small.php'; ?> <?php endif;?> <?php endwhile; }?> <?php wp_pagenavi( array( 'query' => $querysn ) );?> 

That is, the 1st post has template A, the 2nd and 3rd posts have template B, and all the rest that go further, the template B. What it looks like now:

 post-1 post-2 post-3 post-4 ... post-last 

All posts, starting with the 4th, I try to wrap in a separate container to get the following:

 post-1 post-2 post-3 <div class="x"> post-4...post-last </div> 

I do not understand how to do this. Please help. Thank you in advance.

    1 answer 1

    Delay through switch, j, wrap into a function and call.

     switch ($c) { case 1: include 'template-parts/content-news-first-fullheight.php'; break; case 2: include 'template-parts/content-news-small-fullheight.php'; break; case "3": include 'template-parts/content-news-small-fullheight.php'; break; case default: echo "Other situation"; break; } 
    • I understand that your code changes the type of conditions. But, unfortunately, I still can’t get the container to wrap the posts I need in the form: post-1 post-2 post-3 <div class = "x"> post-4 ... post-last </ div > (in the comments do not insert the code, edited the question for clarity) - AliceD