WooCommerce offers several default product sorting options, such as sorting by popularity, rating, and price. However, depending on your store’s needs, you may want to customise the product sorting to highlight certain products or create a more personalised shopping experience for your customers.
In this guide, we’ll show you how to modify the product sorting options in WooCommerce using custom code. As always, we recommend adding any custom code to your child theme to ensure your changes are safe from theme updates.
Why Modify Product Sorting?
Customising product sorting can:
- Highlight Key Products: Promote specific products at the top of the list, such as bestsellers or new arrivals.
- Improve User Experience: Tailor the sorting options to align with your customers’ needs.
- Boost Conversions: Direct customers to the products most likely to convert by displaying them prominently.
Step 1: Remove Unwanted Sorting Options
WooCommerce offers several built-in sorting options. If some of these are unnecessary, you can remove them with the following code:
/*
* Snippet: How to Modify Product Sorting in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1585
* Tested with WooCommerce 10.7.0
* "This function removes unwanted sorting options in WooCommerce"
*/
function wcsuccess_remove_sorting_options( $sorting_options ) {
unset( $sorting_options['popularity'] ); // Remove 'Sort by popularity'
unset( $sorting_options['rating'] ); // Remove 'Sort by average rating'
return $sorting_options;
}
add_filter( 'woocommerce_catalog_orderby', 'wcsuccess_remove_sorting_options' );How This Code Works
unset()Function: This function removes unwanted sorting options by their keys (e.g.,'popularity'and'rating').- Filter Hook: The
woocommerce_catalog_orderbyfilter ensures that only the desired sorting options are displayed.
Step 2: Add Custom Sorting Options
To enhance the shopping experience, you may want to add new sorting options, such as sorting by the latest product arrivals or specific product attributes.
/*
* Snippet: How to Modify Product Sorting in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1585
* Tested with WooCommerce 10.7.0
* "This function adds custom sorting options to WooCommerce"
*/
function wcsuccess_add_custom_sorting_options( $sorting_options ) {
$sorting_options['latest'] = __( 'Sort by latest arrivals', 'woocommerce' );
return $sorting_options;
}
add_filter( 'woocommerce_catalog_orderby', 'wcsuccess_add_custom_sorting_options' );How This Works
- Custom Sorting Option: The new sorting option,
'Sort by latest arrivals', is added to the product sorting dropdown. - Language Translation Support: The
__()function ensures the text can be translated if needed.
Step 3: Set a Default Sorting Option
You can set a new default sorting option to improve the browsing experience by guiding customers toward a specific selection.
/*
* Snippet: How to Modify Product Sorting in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1585
* Tested with WooCommerce 10.7.0
* "This function sets a default sorting option in WooCommerce"
*/
function wcsuccess_set_default_sorting( $sort_by ) {
return 'price'; // Set the default sorting to 'Sort by price'
}
add_filter( 'woocommerce_default_catalog_orderby', 'wcsuccess_set_default_sorting' );How This Works
- Default Sorting: The code sets the default sorting to
'price'. You can change'price'to any other sorting key (e.g.,'latest'or'popularity').
Step 4: Use Shortcodes to Display Products with Custom Sorting
If you want to display products sorted by specific criteria within a page or post, you can use a WooCommerce shortcode:
echo do_shortcode('[products orderby="price" order="asc"]');This shortcode displays products sorted by price in ascending order. You can modify the orderby and order parameters to suit your needs.
Best Use Cases for Custom Sorting
- Seasonal Promotions: Highlight seasonal products by adding custom sorting options, such as “Winter Collection” or “Summer Deals.”
- New Arrivals: Ensure customers see the latest products by setting the default sorting to “Latest Arrivals.”
- Personalised Shopping: If your store offers specific product categories (e.g., electronics or fashion), add sorting options that cater to these segments.
Conclusion
Customising product sorting in WooCommerce helps you create a tailored shopping experience for your customers. By removing unnecessary sorting options, adding new ones, and setting default criteria, you can highlight key products and boost conversions.
Always test your changes on a staging site before applying them to your live store. Use a child theme to ensure your modifications aren’t lost during theme updates. For further WooCommerce customisations, check out our WooCommerce Visual Hooks Guide and wp-config generator.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

