Home > Back-end >  Sort WooCommerce products reviews by date
Sort WooCommerce products reviews by date

Time:11-13

One question please, how could I sort product reviews of WooCommerce by date in WP_Query? 'orderby'=> 'date' is not working. Thank you in advance!

CodePudding user response:

Try this, from the WordPress Dashboard, go to Settings, Discussion and set "Comments should be displayed with the [Older] comments at the top of each page" to "Newer"

CodePudding user response:

If there is no special condition that forces you to use WP_Query, you can use WP_Comment_Query or

$args = array ('post_type' => 'product');
$comments = get_comments( $args );

these code to get product reviews. If you choose using one of those, as it states in the documentation, by default 'orderby' is set for 'comment_date_gmt'. Then all you need to set order ASC or DESC, which is by default DESC.

  • Related