重命名 Woocommerce 单个产品页面中的描述选项卡

Rename Description tab in Woocommerce single product page

我在 function.php 中粘贴了这段代码,但它没有按预期重命名产品页面选项卡 (http://www.noushasasart.com/product/harsh-bark/)

function woo_remove_product_tabs($tabs) {
    unset($tabs['reviews']);    // Remove the reviews tab
    $tabs['description']['title'] = __('Additional Information');  // Rename the 

    description tab        
    return $tabs;
}

我该如何解决这个问题?

您忘记了过滤器挂钩:

add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
function woo_customize_tabs( $tabs ) {

    unset($tabs['reviews']);    // Remove the reviews tab

    $tabs['description']['title'] = __( 'More Information' ); // Rename the description tab

    return $tabs;
}

代码进入您的活动 child 主题(或主题)的 function.php 文件或任何插件文件。

所有代码都在 Woocommerce 3+ 上测试并且有效。


更新(与您的评论相关) |重命名产品描述标题(在选项卡内):

要重命名描述标题,请使用 woocommerce_product_description_heading 过滤器挂钩,方法如下:

add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );
function rename_product_description_heading( $heading ) {
    return  __( 'Additional Information', 'woocommerce' );
}

代码进入您的活动 child 主题(或主题)的 function.php 文件或任何插件文件。

所有代码都在 Woocommerce 3+ 上测试并且有效。


官方相关文档:Editing product data tabs