当没有评论时,我成功地删除了评论选项卡标题上的 (0)。在营销中 - 最好的做法是不显示产品有 0 条评论。这是我放置在我的子主题的 functions.php 文件中的代码,该文件位于 WooCommerce 插件文件 wc-template-function.php 中:
if ( ! function_exists( 'woocommerce_default_product_tabs' ) ) {
/**
* Add default product tabs to product pages.
*
* @param array $tabs
* @return array
*/
function woocommerce_default_product_tabs( $tabs = array() ) {
global $product, $post;
// Description tab - shows product content
if ( $post->post_content ) {
$tabs['description'] = array(
'title' => __( 'Description', 'woocommerce' ),
'priority' => 10,
'callback' => 'woocommerce_product_description_tab'
);
}
// Additional information …Run Code Online (Sandbox Code Playgroud)