I am developing a custom theme and I am trying to sort the products as per the selection made by the use of the dropdown menu. Although the page reloads after the selection is made, the results are not sorted out, regardless of the option chosen. The results are always the same. Can anyone please help sort the products correctly as per the option chosen via the dropdown menu? I am using
do_action('woocommerce_before_shop_loop');to show the sort options.
Here’s the actual code in index.php
<?php $args = array( 'post_type' => 'product', 'orderby' => $_GET['orderby'], ); $wp_query = new WP_Query($args); ?> <?php do_action('woocommerce_before_shop_loop'); ?> <ul class="products_list"> <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php woocommerce_get_template_part('content', 'product'); ?> <?php endwhile; wp_reset_query(); ?> </ul>
- The topic ‘Woocommerce Sorting does not work – Results are always the same’ is closed to new replies.