Remove WooCommerce Product Sorting Options

WooCommerce Logo

Posted on October 10, 2014 in Development, Web

Here’s another WooCommerce trick to add to your arsenal.

When you browse a product category in a WooCommerce powered store, you can sort the products. Depending on your theme, the sorting options may be displayed in a dropdown menu, as a row of buttons/links, etc. Usually the options include ‘default’ sorting, sorting by ‘popularity, ‘rating’, ‘date’, and ‘price’ (asc/desc). Pretty straight-forward. But what if you do not like some of these sorting options and do not want to display them to your site’s visitors? For example you do not have rating/reviews enabled and thus the rating order is irrelevant for your site. Or you do not want the customers to see which products have been added most recently.

Out of the box WooCommerce doesn’t have any back-end setting for this. You can remove the WooCommerce product sorting options through CSS by creating a rule for them that will include display:none;, but that’s ugly. There is a better way to do it and custom WordPress filters come to the rescue.

Simply add the following to your functions.php and you’re good to go:

Enjoyed this post? Share it with others.
Email this to someoneShare on FacebookShare on Google+Tweet about this on Twitter

Responses (6)

  1. Kevin Loader
    March 4, 2015 at 11:31 pm · Reply

    where do i put:
    // Customizes the WooCommerce product sorting options
    // Available options are: menu_order, rating, date, popularity, price, price-desc
    function custom_woocommerce_product_sorting( $orderby ) {
    // The following removes the rating, date, and the popularity sorting options;
    // feel free to customize and enable/disable the options as needed.
    unset($orderby[“rating”]);
    unset($orderby[“date”]);
    unset($orderby[“popularity”]);
    return $orderby;
    }
    add_filter( “woocommerce_catalog_orderby”, “custom_woocommerce_product_sorting”, 20 )

    in the functions.php of the theme? or wordpress? top or bottom? after <?php

    kevin

    • pixel.ninja
      pixel.ninja
      March 5, 2015 at 12:07 am ·

      Hi Kevin,

      You should put it in functions.php of your theme. As a rule of thumb, never modify the core WordPress files. And you can put it at the very end of the functions.php file, just before the closing PHP bracket (?>), so it would look like this:

  2. andy
    October 1, 2016 at 1:10 am · Reply

    Hi,
    What if we wanted to to remove default sorting entirely? And leave no dropdown arrows or whatever?

    Thanks

    • pixel.ninja
      pixel.ninja
      October 1, 2016 at 2:02 am ·

      Hi Andy,

      Try adding this into your theme’s functions.php file:

      remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );

      That would be the preferred solution, but if it doesn’t work for you for some reason, you could hide the sorting dropdown just through CSS:

      .woocommerce-ordering {display: none;}

  3. Joseph
    December 1, 2016 at 4:22 pm · Reply

    Thank you! I needed to remove the sorting box and had the code but lost it. Now, with your comment I found it again. 🙂

    • pixel.ninja
      pixel.ninja
      December 1, 2016 at 5:19 pm ·

      Wonderful. I’m glad you found the post helpful.

Leave a reply

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