If No Reviews Change Reviews Tab Title

This code enables you to change your reviews tab from Reviews ( 0 ) to something else based on the number of reviews published.

add_filter( 'woocommerce_product_reviews_tab_title', 'wpsitesdotnet_woocommerce_reviews_tab_title' );
function wpsitesdotnet_woocommerce_reviews_tab_title( $title ) {

    global $product;
    
    $count = $product->get_review_count();
    
    if ( $count === 0 ) {
    
        return __( 'Leave a Review', 'woocommerce' );
        
    }
    
    return sprintf( __( 'Reviews (%d)', 'woocommerce' ), $count );
    
}

In this case, if reviews count is 0, the title is modified from Reviews ( 0 ) to Leave a Review.

Paste the code into your child themes functions file or PHP code snippets plugin.

Or, you can copy over the WooCommerce single-product-reviews.php file to your-child-theme/woocommerce/single-product-reviews.php and modify it there but you’ll need to update the file when WooCommerce does otherwise you’ll get notices in the backend when you are logged in.

The code is tested and works.

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.