Sha*_*haf 3 php wordpress tabs product woocommerce
我将此代码粘贴到 function.php 中,但它没有按预期重命名产品页面选项卡(http://www.nousasasart.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;
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
你忘记了过滤器钩子:
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;
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(或主题)的 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' );
}
Run Code Online (Sandbox Code Playgroud)
代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中。
所有代码都在 Woocommerce 3+ 上进行了测试并且可以正常工作。
官方相关文档:编辑商品数据标签