there are 3 types of comments in the woocommerce reviews tab: reviews(for customers who bought already), questions (for those who don't bought yet) and comments (it's the reply from shop manager). But I don't know how to output questions and their corresponding comments in the same list like:

Question 1 - Comment 1 --Comment 1.1 Question 2 - Comment 2

while there are some other comments (reply) for reviews. My code is:

<ol class="commentlist">
        <?php wp_list_comments( array(
                'callback'     => 'wc_product_reviews_XH_contributions',
                'max_depth'    => 2,

'type' => 'questions', 'end-callback' => 'wc_product_reviews_XH_comment_form', ) ); ?>

In this case I only get the questions without comments below. I changed the code into:

$comments = get_comments( array(
'type__in' => array('questions','comments'),
'status' => 'approve',

) );

<ol class="commentlist">
        <?php wp_list_comments( array(
                'callback'     => 'wc_product_reviews_XH_contributions',
                'max_depth'    => 2,
                'end-callback' => 'wc_product_reviews_XH_comment_form',
            )  , $comments); ?>

However, I get all comments including those below reviews.

Is there anyway to only get those questions with their comments?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.