Here, We explain how to move ‘Reviews’ tab to first position among ‘description’ and ‘additional information’ tabs on a WooCommerce website. By this we can give more visibility to reviews. We have already posted a code that shows reviews separately out of the tabs section. Now, lets move the ‘Reviews’ tab position in the tabs section on WooCommerce product pages.
Place to add this Code: On WordPress Dashboard, hover on Appearance > Theme Editor and open the functions.php file. Add the following code at the end.
add_filter( 'woocommerce_product_tabs', 'wpd_wc_move_product_review_tab', 1005 );
/**
* Move Reviews tab before Description tab
*
* @param array $tabs Array of tabs.
* @return array
*/function wpd_wc_move_product_review_tab( $tabs ) {
global $product, $post;
$new_tabs = array();
if ( comments_open() ) {
$new_tabs['reviews'] = $tabs['reviews'];
unset( $tabs['reviews'] );
if ( $post->post_content ) {
$new_tabs['description'] = $tabs['description'];
unset( $tabs['description'] );
}
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
$new_tabs['additional_information'] = $tabs['additional_information'];
unset( $tabs['additional_information'] );
}
$tabs = array_merge( $new_tabs, $tabs );
}
return $tabs;
} Under WooCommerce filters, we can add/edit/delete the existing tabs with the woocommerce_product_tabs filter. So first we have to check whether Reviews Tab is active or not.
Here, First,we are creating a new tabs array variable to check whether reviews form is active or not (use if it is necessary). If reviews form is active, then we can re-position each tab accordingly.
After updating this code to your functions.php, you can see that reviews tab is moved to first position and this helps you to gain more reviews and ratings.
Some of our readers asked us how to disable plugin updates in WordPress? Earlier there…