Bookmark

No account yet? Register

Difficulty: Easy

Here we will cover how to hide review count number on your WooCommerce store. Hiding the review count is very simple and can be done like many other things on your WooCommerce store by adding code to your Functions.php file in your theme folder.

TLDR
File: Functions.php

add_filter( 'woocommerce_product_tabs', 'wp_woo_rename_reviews_tab', 98);
function wp_woo_rename_reviews_tab($tabs) {
    global $product;
    $check_product_review_count = $product->get_review_count();
    if ( $check_product_review_count == 0 ) {
        $tabs['reviews']['title'] = 'Reviews';
    } else {
        $tabs['reviews']['title'] = 'Reviews('.$check_product_review_count.')';
    }
    return $tabs;
}

Hiding review count

Customizing functions.php file in WordPress

To hide your review count number first navigate to your admin interface and then go to Appearance and then under Appearance select Theme Editor.

After navigating there you will see a windows like this one below. In there select Theme Functions (functions.php) and then at the end put this code.

add_filter( 'woocommerce_product_tabs', 'wp_woo_rename_reviews_tab', 98);
function wp_woo_rename_reviews_tab($tabs) {
    global $product;
    $check_product_review_count = $product->get_review_count();
    if ( $check_product_review_count == 0 ) {
        $tabs['reviews']['title'] = 'Reviews';
    } else {
        $tabs['reviews']['title'] = 'Reviews('.$check_product_review_count.')';
    }
    return $tabs;
}

Click on button bellow to update your file/save changes and that’s it. Now your WooCommerce products will have a hidden review count if there are no reviews.

Editing the code

There are a few possibilities on how you can edit this code to fit your purpose. Maybe you don’t want to hide Review number if there are 0, maybe you want to hide them when they are less then 1 or 2 etc. Here is a short list of the coding examples and how to edit them in order for them to fit you purpose.

Editing number of reviews

If you want to change number of reviews to hide when they are less then some number you can easily do that by modfiying the if statment and changing it to something like this.

if ( $check_product_review_count <= 2 )

in the example above we changed the number to 2 so now the review count will stay hidden for all products that have less than 2 reviews. Also we changed the comparison to “<=” which means less than (“==” means equal, “>=” means more than).

Permanently hiding review count

To permanently hide the review count we need to remove the if statment and some other bits of code to accompolish that. After doing so the final code looks like this:

add_filter( 'woocommerce_product_tabs', 'wp_woo_rename_reviews_tab', 98);
function wp_woo_rename_reviews_tab($tabs) {

    $tabs['reviews']['title'] = 'Reviews';

    return $tabs;
}

Write A Comment