WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Woocommerce Sorting does not work - Results are always the same (2 posts)

  1. ewdrobert
    Member
    Posted 1 year ago #

    Hi,
    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>

    http://wordpress.org/extend/plugins/woocommerce/

  2. Mr.Antonio
    Member
    Posted 6 months ago #

    I have this problem, have you find solution?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic