< ?php if ( have_posts() ) { $post = $posts[0]; $c = 0; $i = 0; while ( have_posts() ) { the_post(); // start a new row for the first post and every three posts if ( ! $paged && ( 0 == $c || 0 == ( $c % 3 ) ) ) { get_template_part( 'template-parts/content', 'aktuelles-first' ); echo my_code_open_row(); } else { get_template_part( 'template-parts/content', 'aktuelles' ); } // close the opened divs above if ( $i > 2 ) { echo my_code_close_row(); $i = 0; // Reset the row close counter } $c++; $i++; } // Close the row if we never get to the row closing // before we leave the loop if ( $i < 2 ) { echo my_code_close_row(); } } ?>