0
I have a wp_query that filters three categories cars, clothes and music, the order is in Random.
I would like the result to alternate without repeating the category.
<ul>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'category_name' => 'carros, roupas, musica',
'orderby' => 'rand',
'paged' => $paged,
'posts_per_page' => 6
);
$wp_query = new WP_Query($args);
if($wp_query->have_posts()):
while($wp_query->have_posts()):
$wp_query->the_post();
?>
<li>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
?>
<figure class="fotos-secao">
<a class="chocolat-image" href="<?php echo $thumb_url; ?>" title ='<?php the_title_attribute(); ?>'>
<img src="<?php echo $thumb_url; ?>" alt="" class="img_gallery">
</a>
</figure>
</li>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p>Não entendi o que procura.</p>
<?php endif; ?>
</ul>