# "Most Reviewed" Sorting Option

> Adds a "Sort by most reviewed" choice to the shop so shoppers can find the products other customers talk about most.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, sorting, reviews
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-sort-by-most-reviewed/

## Code

```php
add_filter( 'woocommerce_catalog_orderby', function ( $options ) {
    $options['reviews'] = 'Sort by most reviewed';

    return $options;
} );

add_filter( 'woocommerce_get_catalog_ordering_args', function ( $args, $orderby ) {
    if ( 'reviews' === $orderby ) {
        $args['orderby']  = array( 'meta_value_num' => 'DESC', 'date' => 'DESC' );
        $args['order']    = 'DESC';
        $args['meta_key'] = '_wc_review_count'; // phpcs:ignore WordPress.DB.SlowDBQuery
    }

    return $args;
}, 10, 2 );
```

## Notes

Uses the review count WooCommerce already stores, so it adds no extra work per page.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Most Reviewed" Sorting Option" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
