Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.