I am wrapping every 3 elements in my loop in a wrapper div like this:
$query = array(
\'post_type\' => \'post\',
);
$i = 1;
$posts = new WP_Query( $quer
Add the wrapper inside:
$query = array(
'post_type' => 'post',
);
$i = 1;
$posts = new WP_Query( $query );
$out = '';
$endingNeeded = false;
if ($posts->have_posts()){
while ($posts->have_posts()){
if($i % 3 == 1) {
$out .= '';
$endingNeeded = true;
}
$posts->the_post();
$out.= '
//content here
';
if($i % 3 == 0) {
$out .= '';
$endingNeeded = false;
}
$i++;
}
}
if($endingNeeded) {
$out .= '