我正在尝试将标签文本隐藏在Woocommerce Checkout的字段上方,但是我不知道该怎么做。我尝试了很多在网上找到的东西,但它们过时了。
答案 0 :(得分:0)
gmo在以下类似线程中对此进行回答: Woocommerce: remove all form labels at once
// WooCommerce Checkout Fields Hook
add_filter('woocommerce_checkout_fields','custom_wc_checkout_fields_no_label');
// Our hooked in function - $fields is passed via the filter!
// Action: remove label from $fields
function custom_wc_checkout_fields_no_label($fields) {
// loop by category
foreach ($fields as $category => $value) {
// loop by fields
foreach ($fields[$category] as $field => $property) {
// remove label property
unset($fields[$category][$field]['label']);
}
}
return $fields;
}
答案 1 :(得分:-1)
这应该可以满足您的需求。
add_filter( 'woocommerce_checkout_fields', 'remove_checkout_labels' , 10, 1);
function remove_checkout_labels($fields){
$new_fields = array();
foreach($fields as $key => $value){
unset($value['label']);
$new_fields[$key] = $value;
}
return $new_fields;
}