To disable product reviews in WooCommerce using the functions.php file, you can use a combination of the wp_dequeue_script
and wp_dequeue_style
functions to remove the necessary scripts and styles, and the comments_open
and pings_open
filters to disable comments and trackbacks on products.
Here is an example of how you can do this:
// Disable product reviews in WooCommerce
// More snippets at wpunplugged.com
function remove_product_reviews() {
// Remove review form scripts and styles
wp_dequeue_script('woocommerce-review-rating');
wp_dequeue_style('woocommerce-review-rating');
// Disable comments and trackbacks on products
add_filter('comments_open', '__return_false', 10, 2);
add_filter('pings_open', '__return_false', 10, 2);
}
add_action('wp_enqueue_scripts', 'remove_product_reviews');
This code will remove the review form scripts and styles, and disable comments and trackbacks on products.
It’s important to note that this code will only remove the review form and disable comments and trackbacks on the front-end of your site. If you want to completely remove the review functionality from the back-end as well, you will need to use a plugin or additional code to do so.