I have this code that set reviews tab to show first before item description.
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
return $tabs;
}
Its works fine, But i want to set it to do it only if the number of reviews high from 0.
Something like :
function woo_reorder_tabs( $tabs ) {
if(is_review()){
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
return $tabs;
}
}
Is there any hook/ function / filter to get number of product reviews?
Thanks.
reviews in woocommerce is just comments in wordpress… so using get_comments_number should work.
Code didn’t work above. You need to add in both parts for it to work. See below.