I have 4 bootstrap columns that each have unique styling. How can I insert and close <div class="row"> around these being that the query could have 1 or 3 results are well as 2 or 4. If there is only one result the row should span only around the first column, if there are 2 results, it should span around the first two columns, if there are three it should start a new row after the end of the first row, and end after the third column, and if there are 4, then the second row should span around the 3rd and fourth columns.
Here is the code I need to insert the rows into:
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 4,
);
$arr_posts = new WP_Query($args);
if ($arr_posts->have_posts()) :
$i = 0;
while ($arr_posts->have_posts()) :
$arr_posts->the_post();
if ($i == 0) :
?>
<div class="col-lg-6 some-class">
</div>
<?php
elseif ($i == 1) :
?>
<div class="col-lg-6 some-class1">
</div>
<?php
elseif ($i == 2) :
?>
<div class="col-lg-6 some-class2">
</div>
<?php
elseif ($i == 3) :
?>
<div class="col-lg-6 some-class3">
</div>
<?php
endif;
$i++;
endwhile;
endif;
?>