Punct Ulica
Punct Ulica

Reputation: 197

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:

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?

Upvotes: 4

Views: 10543

Answers (2)

Frithir.com
Frithir.com

Reputation: 295

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' ); ?>

Upvotes: 3

Punct Ulica
Punct Ulica

Reputation: 197

Found the solution thanks to Anand. the .woocommerce-ordering class had a display:none on it.

Upvotes: 1

Related Questions