loops - PHP: Wrap every 3 in array then place remaining -


i have loop of posts splits list item after every 4 posts. however, not want list item have less 3 , no more 4. here loop:

echo '<li class="match">';   while ( $player_query->have_posts() ) {     $player_query->the_post(); $i3++; $i5++;      echo '<span class="team team-' . ( $i5 - 1 ) . '"><span class="team-name">' . get_the_title() . '</span>';     echo $select . '</span>';      if ( $i4 === 2 && $count == $i5 && checknum( $count ) === true  && needbye( $count ) === true ) {       echo '</li><li class="match bye">';     } elseif ( 0 == $i3%$i4 && $count != ( $i5 - 1 ) ) {       echo '</li><li class="match">';     } else {       echo '';     }   } echo '</li>'; 

example of have 10 posts:

<li>   post 1   post 2   post 3   post 4 </li> <li>   post 5   post 6   post 7   post 8 </li> <li>   post 9   post 10 </li> 

but, want is:

<li>   post 1   post 2   post 3   post 10 </li> <li>   post 3   post 4   post 5   post 6 </li> <li>   post 7   post 8   post 9 </li> 

anyone have clues this? or, can point me? , appreciated!

// try echo '<li class="match">'; $counter = 0; while ( $player_query->have_posts() ): $player_query->the_post(); ?>  <span class="<?= ($counter%3 == 0)?'match':''; ?>"></span>  <?php $counter +=1; endwhile; echo '</li>'; 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -