Featured products should be at top of posts list
-
Hello, I have query with arguments for products, but I want to display featured products first and other products by date after them.
P.S. I can’t do this by 2 different queries, because on this pages there is ajax load more (with pagination), so I should have all posts in 1 query
$cate = get_queried_object(); $cateID = $cate->term_id ?? null; $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'orderby' => 'date', // ... order by date 'order' => 'DESC', // ... most recent first 'meta_query' => array( array( 'key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC' ) ) ); if($cateID) { $args['tax_query'] = array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $cateID, ) ); } $query = new WP_Query( $args ); while ($query->have_posts()) { $query->the_post(); /** * Hook: woocommerce_shop_loop. */ do_action('woocommerce_shop_loop'); wc_get_template_part('content', 'product'); } wp_reset_postdata();
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Featured products should be at top of posts list’ is closed to new replies.