我如何从id中获取值,php



与新宽度和新高度连接的位置

管理数据选项卡控制和设置开始大小

如果我改变占位符的值,并将其设置为8或其他不工作,如果它工作,我需要它从id获取值

woocommerce_form_field('custom_field1', array(
'id' => 'Hwidth',
'label' => __( 'Width', 'woocommerce' ),
'placeholder' => 'id=Hwidth',
'css'  => 'width: 20px;',
'type' => 'number',
'required'    => true, // Or false
'custom_attributes' => array(
'step' => '0.1',
'min' => '3' 
)
)
);

未给woocommerce_form_field函数赋值。下面是你需要的代码:

$width  = get_post_meta( $post_id, '_custom_width', true );
woocommerce_form_field( '_custom_width', // Field ID
array(
'name'              => '_custom_width',
'placeholder'       => 'Please enter width',
'css'               => 'width: 20px;',
'type'              => 'number',
'required'          => true, // Or false
'custom_attributes' => array(
'step' => '0.1',
'min' => '3' 
),
),
$width // Saved Value 
);

最新更新