skip to Main Content

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!

2

Answers


  1. 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"

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search