How to hide dropdown product sorting options in WooCommerce

woo expert

Every online store created with WooCommerce has in its product catalog a dropdown from which the customer can sort the products to their liking.

Some time ago we showed the mystery of the default order of products in WooCommerce.

But today we’re going to spin a little finer, and we will learn how to hide some of the options that appear in the drop-down order of the products, to leave only those that we want to be visible because I do not know what you think, but to me, it has always seemed to me that gives too many options, and more options aren’t ALWAYS good.

Wouldn’t it be better to remove so many product ordering options?

So, for example:

/* Hide dropdown sorting options */
add_filter( 'woocommerce_catalog_orderby', 'wphelp_hide_dropdown_sorting_options' );
function wphelp_hide_dropdown_sorting_options( $options ){
unset( $options[ 'popularity' ] );
unset( $options[ 'rating' ] );
unset( $options[ 'date' ] );
//unset( $options[ 'menu_order' ] );
//unset( $options[ 'price' ] );
//unset( $options[ 'price-desc' ] );
return $options;
}Code language: PHP (php)

In the above code we deactivate (unset) those sorting options that we want to hide from the list, and comment out the line (//) of the ones we want to show.

You can add this code to the end of the functions.php file of the active child theme or to your own plugin.

What remains is this:

Much better, isn’t it?

The options that we can enable/disable are these:

  • menu_order – Default order, as we have already seen and learned to change.
  • popularity – Order by popularity, by number of sales.
  • rating – Order by average rating.
  • date – Order in which recently added products are displayed first.
  • price – Order by price: from lowest to highest price.
  • price-desc – Order by price: from highest to lowest price.

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

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

Scroll to Top