You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求修改WooCommerce代码:自动为产品描述标签添加产品标题

WooCommerce产品标签自定义代码修改方案

以下是实现移除additional_information标签,并将description标签标题改为Detail Product + 产品标题的完整代码:

add_filter( 'woocommerce_product_tabs', 'customize_product_tabs', 98 );
function customize_product_tabs( $tabs ) {
    // 移除additional_information标签
    unset( $tabs['additional_information'] );

    // 获取产品标题并拼接新标签标题
    $product_title = get_the_title();
    $tabs['description']['title'] = 'Detail Product ' . $product_title;

    return $tabs;
}

代码说明

  • 借助woocommerce_product_tabs过滤器钩子修改产品标签配置
  • 通过unset()直接移除不需要的additional_information标签
  • 使用get_the_title()获取产品标题(避免直接输出的问题),与固定文本拼接后替换原description标签的标题
  • 将代码添加到当前主题的functions.php文件,或自定义功能插件中即可生效

内容的提问来源于stack exchange,提问作者Seo Xanh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 18:33:10