WooCommerce: Remove, Rename, Add “Sorting” Options @ Shop

We’ve seen in the past how to completely remove the “Default Sorting” dropdown that shows in the WooCommerce Shop, Category and Product Archive pages.

Sometimes, however, you might just need to remove one of the default options, rename a sorting option accordingly to your needs or even add a brand new sorting method. As usual, a few lines of PHP are sufficient to achieve anything, thanks to WooCommerce hooks and filters.

Remove, Rename or Add Options to the WooCommerce “Default Sorting” Dropdown

PHP Snippet #1: Remove a Sorting Option @ WooCommerce Shop

/**
* @snippet       Remove Sorting Option @ WooCommerce Shop
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.8
* @community     https://businessbloomer.com/club/
*/
 
add_filter( 'woocommerce_catalog_orderby', 'bbloomer_remove_sorting_option_woocommerce_shop' );
 
function bbloomer_remove_sorting_option_woocommerce_shop( $options ) {
   unset( $options['rating'] );   
   return $options;
}
 
// Note: you can unset other sorting options by adding more "unset" calls... here's the list: 'menu_order', 'popularity', 'rating', 'date', 'price', 'price-desc'

PHP Snippet #2: Rename a Sorting Option @ WooCommerce Shop

/**
* @snippet       Rename a Sorting Option @ WooCommerce Shop
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 3.8
* @community     https://businessbloomer.com/club/
*/
 
add_filter( 'woocommerce_catalog_orderby', 'bbloomer_rename_sorting_option_woocommerce_shop' );
 
function bbloomer_rename_sorting_option_woocommerce_shop( $options ) {
   $options['price'] = 'Sort by price (asc)';   
   return $options;
}

PHP Snippet #3: Add a Custom Sorting Option @ WooCommerce Shop

In this example, we will create a new sorting option called “Sort by name (desc)” that will indeed sort products by title (descending order).

/**
* @snippet       Add a Custom Sorting Option @ WooCommerce Shop
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @testedwith    WooCommerce 4.0
* @community     https://businessbloomer.com/club/
*/
 
// 1. Create new product sorting rule
 
add_filter( 'woocommerce_get_catalog_ordering_args', 'bbloomer_sort_by_name_woocommerce_shop' );
 
function bbloomer_sort_by_name_woocommerce_shop( $args ) { 
   $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
   if ( 'name' == $orderby_value ) {
      $args['orderby'] = 'title';
      $args['order'] = 'DESC';
   } 
   return $args;
}
 
// 2. Add new product sorting option to Sorting dropdown
 
add_filter( 'woocommerce_catalog_orderby', 'bbloomer_load_custom_woocommerce_catalog_sorting' );
 
function bbloomer_load_custom_woocommerce_catalog_sorting( $options ) {
   $options['name'] = 'Sort by name (desc)';
   return $options;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]
  • WooCommerce: How to Remove the “Default Sorting” Dropdown
    If the WooCommerce product sorting functionality (“Default Sorting” dropdown) is a waste of space or you don’t need that select box at all, you may want to remove it. No matter if you prefer custom code or a simple plugin – hiding the product sorting dropdown is a piece of cake. Enjoy!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

52 thoughts on “WooCommerce: Remove, Rename, Add “Sorting” Options @ Shop

  1. Question. I have followed the guide, and it works for the default wordpress shop page, but I used woocommcerce’s all products block and made a new store page. It was necessary to use a custom page as my client wanted to change the slug for the page… The function does not change the drop down list for the new page. Do you know of a fix for this?

    1. Hi Ryan, have you tried with the WooCommerce products shortcode instead?

  2. This is great! I’d like to combine two of your tutorials but I can’t figure out how.

    I want to sort by default sorting order, but also move all out of stock items to the end of the list. Is this possible?

    1. Hi Tom thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Simple and useful, thank you.

  4. Hello! I have Rife Free theme. Product sorting options do not show on the shop page. How can I fix this?

    1. Hey Adrian, thanks so much for your comment! Yes, this is definitely possible, but Iโ€™m afraid itโ€™s custom work. If youโ€™d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Hi and thanks for your code!
    But it doesn’t work for me.
    Any idea of how to hide some “sort by” entries on the drop down menu?

    1. Hi Aline, please share your code

  6. Hi thank you for this. but can you tell me how to add categories in this? thank

      1. Thanks for reply. I think i am mistaken. I like to include categories in the default sorting in shop page. Can i do this?

        1. Ah ok, yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  7. Dear,
    is it possible to insert image, icon etc… instead Default Sorting .woocommerce .woocommerce-ordering .ordering-selector-wrapper
    Idea is to have image to represent this wrapper and on click to open drop down .

    Best regards

    1. Anything is possible ๐Ÿ™‚

  8. For the third snippet you didn’t actually set $orderby_value and that value isn’t passed into the function so it doesn’t ever fire.

    You can set it like this though:

    $orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    1. Thank you!

  9. Hi Rodolfo,
    I used the 3rd snippet to order products by random and works fine, but also this list need to be with available products in the beggining. Is it possible to do this?

    1. Hello there, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  10. How can I remove, not hide, but actually remove the Default Sorting drop down box. It leaves too much white space at the top of the page above the product listings. I found some CSS to hide it but the white space remains. Im looking for CSS to actually remove it to adjust the padding and not leave so much whitespace.

    (Would also like to remove the empty space at the top above my logo too, it’s about a half inch to an inch of whitespace at the top when scrolling)

    Thanks in advance and have a good one!

  11. Can I sort by an equation? price*total_sales desc for best selling by total $ sold?

    1. Hi Aaron, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  12. works great!

    But…. i got an sorting option called “biggest saving” which i want to remove, what’s the unset option for that one? Can’t find it anywhere.

    Thanks in advance

    1. Not sure, that’s not default WooCommerce

  13. Hi, I used one of the custom sorting methods where menu order value is set to negative starting from -1. When I tried this code , It did not took into consideration the Custom sorting while using ‘Sort by Name’. Please help me find a fix to it. Thanks you so much blogs like this help us new developers & designers to learn and grow and also get our work done. Hoping for a quick reply.

    1. Hi there, not sure about negative values, sorry

  14. Hi how to sort by recent comment in woocommerce?

    1. Hi Drew, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  15. This article helped me a lot.
    Rodolfo, when it comes to web development, your blog/website is the most efficient blog/website I ever come across.
    THANK YOU for this amazing piece of work!

    1. Thank you!

  16. Rodolfo, another great tutorial that saved my life! Thank you very much for sharing your knowledge. I’m a new developer and your tutorials have provided great help to me!

    1. Fantastic!

  17. Nice tutorial! I just need to fix the ordering. Thanks.

    1. Cool!

  18. Hello!!
    Is it possible to add a sort by “_featured” products? I couldn’t do achieve it with your code.
    Thanks!

    1. Hello Walter, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  19. Hi,
    I wanted to replace the default sorting option by the category shop list.
    Like with a portfolio listing.
    Do you have an idea of how I can do it ?
    Regards

    1. Hello Cine, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  20. legend just what I neeed

    1. Cool!

  21. Looking at this allows for the removal of items within the sort function…. is the a way to remove the entire thing?

    The sorting div, row, container … whatever?

  22. Hello Rodolfo.

    I need to set my woocommerce default product sorting by Product Tittle.

    I will remove the filter sorting, caus will not used in my project.

    But it still in sort default by another order, and not for Product Name.

    how can i do this?

    tks!

    1. Hello Carlos, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  23. Is there a way to change the order of the sorting options?
    That would be awesome!

    1. Hello Miriam – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  24. The same that lottie but for my bookmarks. Thanks!! ๐Ÿ™‚

    1. Ahah ๐Ÿ™‚

  25. just what I was looking for

    your website is now my home page!!!

    1. Nice ๐Ÿ™‚

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

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