1. Home
  2. Knowledge Base
  3. WooCommerce Product Filters
  4. FAQ

How to choose the items in the 'Sort' dropdown

WooCommerce provides its own 'Sort' dropdown allowing customers to choose how the list of products is sorted. For example, customers can sort alphabetically, by popularity, or by average rating.

While WooCommerce Product Filters has no built-in options for customizing the content of this dropdown, we have provided a developer filter so that you can do it programmatically. If you don't have a developer who can do this for you then you can request a quote from our customization service.

WooCommerce Product Filters uses the same sort options as the built-in WooCommerce catalog ordering dropdown. If you want to change the options that appear in the sort dropdown, you can do this using the woocommerce_catalog_orderby filter.

For example, you could remove unwanted sort options or add your own custom ones:

add_filter( 'woocommerce_catalog_orderby', 'barn2_customize_sorting_options' );

function barn2_customize_sorting_options( $sort_options ) {
// Remove the "Sort by popularity" option
unset( $sort_options['popularity'] );

// Add a custom option
$sort_options['my_custom'] = __( 'My custom sort', 'your-text-domain' );

return $sort_options;
}

This filter changes the list of options shown in the dropdown. The actual sorting logic needs to be implemented separately if you add a new option.

For more details, see the WooCommerce documentation on custom sorting options.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.