# Latest Product Reviews Dashboard Widget

> Shows the five newest product reviews with star rating, product and approval status on the dashboard, so you can answer or approve them quickly.

- Type: PHP
- Runs: Admin only
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, dashboard, reviews
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-dashboard-latest-reviews/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! current_user_can( 'moderate_comments' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_latest_reviews', 'Latest product reviews', function () {
        $reviews = get_comments( array(
            'post_type' => 'product',
            'type'      => 'review',
            'status'    => 'all',
            'number'    => 5,
        ) );

        if ( ! $reviews ) {
            echo '<p>' . esc_html( 'No reviews yet.' ) . '</p>';
            return;
        }

        echo '<ul>';

        foreach ( $reviews as $review ) {
            $rating = (int) get_comment_meta( $review->comment_ID, 'rating', true );

            printf(
                '<li style="margin-bottom:10px"><span aria-label="%1$s" style="color:#dba617">%2$s</span> <a href="%3$s">%4$s</a>%5$s<br><em>%6$s</em> &ndash; %7$s</li>',
                esc_attr( sprintf( 'Rated %d out of 5', $rating ) ),
                esc_html( str_repeat( '★', $rating ) . str_repeat( '☆', 5 - $rating ) ),
                esc_url( get_edit_post_link( $review->comment_post_ID ) ),
                esc_html( get_the_title( $review->comment_post_ID ) ),
                '0' === $review->comment_approved ? ' <strong style="color:#d63638">' . esc_html( '(pending)' ) . '</strong>' : '',
                esc_html( wp_trim_words( $review->comment_content, 18 ) ),
                esc_html( $review->comment_author )
            );
        }

        echo '</ul>';
    } );
} );
```

## Notes

Pending reviews are marked so you can moderate them from Products > Reviews.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Latest Product Reviews Dashboard Widget" 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/
