0
I have a question. I put the code just below before starting a while but inside the loop, calling the array_shift($cores), it applies the classes while loop is <= the number of indices, that is to say índice 4 he no longer applies the classes.
If I then put 10 items inside the loop, 6 will be without any class probably because this instruction puts index without repeating it.
$cores = ["primary", "secondary", "tertiary", "quaternary"];
shuffle($cores);
LOOP
if ( $empr->have_posts() ) {
while ( $empr->have_posts() ) { $empr->the_post(); ?>
<div class="team-item <?php echo array_shift($cores); ?>"> ...
Question: How to continue applying classes? An example can be viewed here in the session OTHER VENTURES.
Maybe use the
rand()and play the return as index of the array can be a solution, so no array element is removed.– rray