【发布时间】:2022-01-18 22:30:38
【问题描述】:
我想在变体名称后添加内容。
我找到了这个钩子并看到它以前可以工作,但在我的测试中没有:(
我想问一下,有没有其他的钩子/工作方法可以用来添加内容?
add_filter('woocommerce_attribute_label', 'custom_attribute_label', 10, 3);
function custom_attribute_label($label, $name, $product){
$taxonomy = 'pa_' . $name;
if ($taxonomy == 'pa_size')
$label .= '<div class="custom-label">' . __('MY TEXT', 'woocommerce') . '</div>';
return $label;
}
代码参考:
Adding a custom text next to a specific product attribute label in WooCommerce
【问题讨论】:
标签: php wordpress woocommerce hook-woocommerce woocommerce-theming