php - 从 Woocommerce 中的产品评论选项卡菜单项中删除 (0)
问题描述
我刚刚在子函数 php 中添加了此代码,它可以从评论中删除零号,但是当任何产品中未启用评论时它会显示错误。我该如何解决?
// remove zero reviews
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;
}
错误:
解决方案
推荐阅读
- r - How can I order the bars in my histogram?
- python - How to add attribute to class before __init__?
- python - Create a directory in /var/lib
- javascript - 使用保存和新建按钮时如何保留父值
- php - 如何使用 laravel-websockets 使 URL 可用于在公共频道中注册?
- javascript - How to hide wrapped element using v-if
- vue.js - 如何使我的自定义 CSS 和 Javascript 文件在我的 vuejs 应用程序中工作
- c# - WPF Task.Run ==> 线程无法访问此对象
- spring - Jhipster Okta 离子
- c - ISO C String Concatenation unwanted @ character at the very end