I have a problem with my custom snippet.
It inconsistently shows me 0-3 products.
<?php
$args = array('post_type' => 'product', 'posts_per_page' => 3, 'orderby' => 'rand');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
global $product; ?>
<div class="col-lg-4">
<?php wc_get_template_part(PAGE_NAME . '/content', 'product'); ?>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
Setting ‘orderby’ to ‘date’ always shows me 3 newest products but I want it to be random from all available products.
New contributor
Grawlas Kontakt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.