How to remove default sorting from your WooCommerce product pages

Do you need to remove the drop down default sorting provided by WooCommerce on your product pages? Perhaps you don’t want sorting at all on your store, or you want to move it to another location in your theme?

It’s really easy to do so and in this snippet we’ll show you how.

Firstly, we’re going to implement the standard approach to removing sorting. Themes like Storefront modify how and when the sorting is loaded and we’ll cover how to get around that shortly.

Removing the default sorting from WooCommerce

<?php
/**
 * Remove sorting from WooCommerce.
 */
function thenga_remove_filtering() {
   remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );

Using the code above you will remove the sorting from standard WooCommerce. All we do is remove the action that adds it in the first place.

Removing the default sorting from Storefront

If you look at the Storefront theme code deeply, you’ll notice that the theme uses the above method to remove sorting and then adds in it’s own custom sorting functions. So to remove the sorting from Storefront, use the following snippet which will remove the actions that are added by the Storefront theme for sorting products.

<?php
/**
 * Remove sorting from Storefront.
 */
function thenga_remove_filtering() {
   remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
   remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );

Getting rid of sorting in other themes

If none of the above methods work, your theme probably implements custom sorting just like Storefront uses it’s own methods above. You will need to dig in to your theme and figure out the names and positions of the actions it adds for sorting products. Once you have those, you can remove them using the same snippet above. A search for woocommerce_catalog_ordering or woocommerce_after_shop_loop on your themes codebase will generally return the name and position of your themes sorting functions.

We hope you found this useful. Be sure to check out some of our WooCommerce products to improve your WooCommerce store.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.