Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Can I show multiple review sections for different products on one page


Can I show multiple review sections for different products on one page


Yes, you can display reviews for multiple products on a single page using WooCommerce shortcodes. Here are a couple methods to achieve this:

Using a Custom Shortcode

You can create a custom shortcode in your theme's functions.php file that displays reviews for a specific product based on the product ID passed as a parameter. Here's an example:

php
add_shortcode( 'product_reviews', 'bbloomer_product_reviews_shortcode' );

function bbloomer_product_reviews_shortcode( $atts ) {
    if ( empty( $atts ) || ! isset( $atts['id'] ) ) return '';

    $comments = get_comments( 'post_id=' . $atts['id'] );
    if ( ! $comments ) return '';

    $html = '<div class="woocommerce-tabs"><div id="reviews"><ol class="commentlist">';
    foreach ( $comments as $comment ) {
        $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
        $html .= '<li class="review">' . get_avatar( $comment, '60' );
        $html .= '<div class="comment-text">';
        if ( $rating ) $html .= wc_get_rating_html( $rating );
        $html .= '<p class="meta"><strong class="woocommerce-review__author">' . get_comment_author( $comment) . '</strong></p>';
        $html .= '<div class="description">' . $comment->comment_content . '</div></div></li>';
    }
    $html .= '</ol></div></div>';
    return $html;
}

Then, simply insert the shortcode `[product_reviews id="123"]` for each product you want to display reviews for on your page, replacing "123" with the actual product ID[3].

Using a Plugin

Another option is to use a plugin like WooCommerce Product Reviews Pro, which allows you to display reviews for multiple products on a single page using shortcodes. The plugin provides additional features like filtering reviews by type, rating, and product[5].

To use it, install the plugin, go to WooCommerce > Reviews to manage reviews, and then generate a shortcode to display reviews for a specific product or category on your desired page.

Summary

By leveraging custom shortcodes or plugins like WooCommerce Product Reviews Pro, you can effectively display reviews for multiple products on a single page in WooCommerce. This provides flexibility in showcasing customer feedback and enhancing the user experience on your site.

Citations:
[1] https://www.8theme.com/topic/how-to-show-all-product-woocommerce-reviews-in-one-page/
[2] https://www.reddit.com/r/woocommerce/comments/1c7ddbq/woocommerce_reviews_consolidating_for_multiple/
[3] https://www.businessbloomer.com/woocommerce-display-product-reviews-custom-page-shortcode/
[4] https://www.youtube.com/watch?v=IXKscIADcbE
[5] https://woocommerce.com/document/woocommerce-product-reviews-pro/