• Resolved Md Abul Bashar

    (@hmbashar)


    I’ve a custom query for showing woocommerce product. Now I want to show sorting system above my query. Like shop page https://prntscr.com/il17ge
    I’ve tried lots of ways. But no success. Also I’ve followed this Article but result same,

    Here is my query codes

    <div class="mproduct-area fix">
    
        <?php
    
            $mproduct = new WP_Query(array(
                    'post_type'     => 'product',
                    'posts_per_page'=> 10,
                    'tax_query' => array(
                        array(
                            'taxonomy' => 'product_cat',
                            'field' => 'slug',
                            'terms' => array( 'combinations' ),
                            'operator' => 'NOT IN'
                            )
                        )                      
            ));
            if($mproduct->have_posts()) : while($mproduct->have_posts()) : $mproduct->the_post(); ?>
    
            <!--Single Product for Mobile Page-->
            <div class="msingle-product fix">
                <div class="msingle-product-image">
                    <a href="<?php the_permalink(); ?>">
                    <?php if(has_post_thumbnail( get_the_ID())){
    
                         echo get_the_post_thumbnail( get_the_ID(), 'com_product_img' );
                    } else {
                        echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />';
                    }
                    ?></a>
                </div>
                <div class="mproduct-price">
                    <h2><strong>Price : </strong> <?php echo $product->get_price_html(); ?></h2>                        
                </div>
                <div class="mproduct-name">
                    <h2><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( $product->get_title() ) ?>"><?php echo esc_attr( $product->get_title() ) ?></a></h2>
                </div>
                <div class="mproduct-add-to-cart">
                    <?php woocommerce_template_loop_add_to_cart(); ?>  
                    <!-- Modal -->
                    <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel"><?php echo esc_attr( $product->get_title() ) ?></h4>
                          </div>
                          <div class="modal-body">
    
                            <div class="msingle-product-image product_img_model">
                                <a href="<?php the_permalink(); ?>">
                                <?php if(has_post_thumbnail( get_the_ID())){
    
                                     echo get_the_post_thumbnail( get_the_ID(), 'com_product_img' );
                                } else {
                                    echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />';
                                }
                                ?></a>
                            </div>
    
                            <div class="mproduct-price">
                                <h2><strong>Price : </strong> <?php echo $product->get_price_html(); ?></h2>                        
                            </div>
                            <div class="product_variable_list">
    
                            <?php wc_get_template_part('content', 'single-product'); ?>
    
                            </div>
                          </div>
                          <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Continue Shipping</button>
                          </div>
                        </div>
                      </div>
                    </div>
                </div>                  
            </div><!--/ Single Product for Mobile Page-->
    
        <?php endwhile; endif;?>
    
    </div>

    codes on pastebin https://pastebin.com/vGpDT7cd
    Which code do I need for show sorting system. Please add that code in my query

    I want to Woocommerce default all sorting list like Default sorting, Sort by popularity, Sort by average rating, Sort by newness, Sort by price: low to high, Sort by price: high to low,

    Advance Thanks for help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How can I display sorting system with my custom query?’ is closed to new replies.