This code enables you to prevent users from sorting by specific key on the shop page in WooCommerce.
By default, there’s 6 catalogue orderby options users can choose from however, for some reason, you may not want them to know which products are the highest rated or which products sell the most in which case you can use code to disable specific sort options.
Add the following code to the end of your child themes functions file or code snippets plugin.
To target specific orderby options, use the keys from this array :
menu_order
popularity
rating
date
price
price-desc
Example :
$orderby === 'rating'
Note : There are ways to remove sorting options from the drop down menu however this would not prevent users from using the options in the address bar which would still enable them to sort by hidden or removed options.
The code in this post completely prevents sorting by specific options so there’s no way possible to get the orderby results which you want removed.