Reputation: 197
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
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
Reputation: 197
Found the solution thanks to Anand. the .woocommerce-ordering class had a display:none on it.
Upvotes: 1