How to Remove WooCommerce Catalog Ordering Options

Code image

I had a few requests after my last post on how to add WooCommerce catalog ordering args, asking how arguments can be removed. With a filter, which is what is used to give us access to these arguments, it is as easy as a little function called unset().

If you look at the WooCommerce code setting up the filters:

All of those keys, menu_order, popularity can be removed by name. So if you want to remove rating and popularity you just do like so

Another alternative is if you just want to leave maybe a couple of the options is to build a new array using the values, say you wanted to only have the pricing options you would maybe do:

And what I might as well tell you here, that you may not know is that the values of the array are the labels the user is seeing in the dropdown, the visible text they select from. So you might want to change those, in which case you can change them one by one like so:

Or if you wanted to change a few of them then you would again perhaps want to build a new options array:

In case you are wondering what the hell the textdomain thingies are this is a great article for you, also please see my article here on adding options to the WooCommerce orderby.

Like the code you see here? You can hire me at - a WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard. See all developers you can hire through Codeable here.

Posted in Code Snippets, Featured, Guides, Help Topics, Woocommerce, Wordpress and tagged .

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.