1

How do you order products in WooCommerce so that products are random, but at the same time featured products show first?

Here is my code:

$args = array(
    'post_type' => 'product',
    'showposts' => $show_posts,
    'meta_key' => '_featured',
    'orderby' => 'meta_value',
    'order' => 'desc',
    'post_status' => 'publish',
    'paged' => $paged
);


$all_products = new WP_Query( $args );

I have tried adding rand after meta_value, but it just randomizes products (in other words the featured ones don't display first).

Thanks in advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.