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

如何移除Woocommerce变体属性标签中的冒号:

WooCommerce移除单商品页变体属性标签末尾冒号方案

你可以直接使用以下完整代码,添加到当前主题的functions.php文件或者自定义代码片段插件中即可生效:

add_filter( 'woocommerce_attribute_label', 'custom_remove_attribute_label_colon', 10, 3 );
function custom_remove_attribute_label_colon( $label, $name, $product ) {
    // 仅限制单商品页面生效,不影响其他页面属性标签展示
    if ( is_product() ) {
        $label = rtrim( $label, ': ' );
    }
    return $label;
}
  • 若需要全局移除所有页面的属性标签冒号,删除代码中的if ( is_product() )判断条件即可
  • 代码添加后若不生效,清理网站缓存、浏览器缓存后再刷新测试即可
  • 如果主题自定义了WooCommerce属性渲染逻辑,可使用CSS方案兜底:
/* 将下方选择器替换为你实际页面变体标签的CSS选择器 */
.single-product .variations label::after {
    content: none !important;
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.27 09:15:01