How to add product sorting dropdown in WooCommerce?

I saw a lot of questions on stackoverflow about removing this dropdown. I want to ADD IT on my theme and it doesn’t work.

I tried adding this:

Read More
add_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );

aaand didn’t work.

What’s the catch? I already have in my archive-product.php this piece of code:

<?php
 /**
 * woocommerce_before_shop_loop hook
 *
 * @hooked woocommerce_result_count - 20
 * @hooked woocommerce_catalog_ordering - 30
 */
 do_action( 'woocommerce_before_shop_loop' );
?>

So the sorting template is included, right? Where am I messing this up?

Related posts

2 comments

  1. First add this to your functions.

    <?php 
     // sorting
     remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
     add_action( 'woo_custom_catalog_ordering', 'woocommerce_catalog_ordering', 30 ); 
    ?>
    

    Then wherever you want to have the sort box just drop it in.

    <?php do_action( 'woo_custom_catalog_ordering' ); ?>
    
  2. Found the solution thanks to Anand. the .woocommerce-ordering class had a display:none on it.

Comments are closed.