Sorting not working
-
How do I sort the products?
$args = array( 'posts_per_page' => $atts['per_page'], 'paged' => $paged, // Use the specified current page 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'post__not_in' => array(get_the_ID()), // Exclude the current product 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $category_id, ), ), ); if($sort_by === 'price') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = '_price'; $args['order'] = 'ASC'; } else if($sort_by === 'price-desc') { $args['orderby'] = 'meta_value_num'; $args['meta_key'] = '_price'; $args['order'] = 'DESC'; } else { $args['orderby'] = $sort_by; } $query = new WP_Query($args);The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sorting not working’ is closed to new replies.