Display Woocommerce Product Reviews outside of Tab
WooCommerce product reviews are an essential part of any e-commerce website. They provide valuable feedback on products, which can help customers make informed purchasing decisions. However, by default, WooCommerce displays product reviews in a tab on the product page. This can make it difficult for customers to find and read reviews. In this article, we will discuss how to display WooCommerce product reviews outside of the tab without using a plugin.
It is important to note that while this method allows you to display product reviews outside of the tab without using a plugin, it is a custom solution and it is not recommended to make direct changes to the parent theme. Instead, it is recommended to use a child theme, which is a separate theme that inherits the functionality of the parent theme. This way, your changes will not be lost when the parent theme is updated. If you have not yet created your child theme, then follow this tutorial to create one.
More articles
Add Buy Now Button in WooCommerce Without Plugin.
How to Create WordPress Child Theme without Plugin.
Allow SVG File Upload in WordPress.
Video Tutorial [Hindi Language]
Steps to Display Woocommerce Product Reviews in a Separate Sections.
Follow below steps:
1) Go to Appereance > Theme File Editor > Functions.php
Below is the image for your reference.
2) Add Below Code in functions.php file.
/**
* Remove Reviews tab
*/
add_filter( 'woocommerce_product_tabs', 'wpamit_remove_product_review_tab', 15 );
function wpamit_remove_product_review_tab( $tabs ) {
//Removing Reviews tab
if ( comments_open() ) {
unset( $tabs['reviews'] );
}
return $tabs;
}
/**
* Add the product reviews
*/
add_action( 'woocommerce_after_single_product_summary', 'wpamit_add_product_reviews', 15 );
function wpamit_add_product_reviews() {
global $product;
if ( ! comments_open() )
return;
?>
<div class="product-reviews">
<h2 class="review-title" itemprop="headline">
<?php printf( __( 'Reviews (%d)', 'woocommerce' ), $product->get_review_count() ); ?>
</h2>
<?php call_user_func( 'comments_template', 999 ); ?>
</div>
<div class="clearfix clear"></div>
<?php
}
It’s done! I hope you learned how to display woocommerce product reviews outside of tab or display reviews in a separate section.