Woocommerce 如何获取自定义元框的值

Woocommerce 如何获取自定义元框的值,woocommerce,meta-boxes,Woocommerce,Meta Boxes,我为产品创建了一些自定义元框 在writepanel-product_data.php中,我添加了: woocommerce_wp_text_input( array( 'id' => 'orario', 'class' => '', 'label' => __('Orario', 'woocommerce') ) ); woocommerce_wp_text_input( array( 'id' => 'luogo_evento', 'class' => '',

我为产品创建了一些自定义元框

在writepanel-product_data.php中,我添加了:

woocommerce_wp_text_input( array( 'id' => 'orario', 'class' => '', 'label' => __('Orario', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'luogo_evento', 'class' => '', 'label' => __('Luogo Evento', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'indirizzo', 'class' => '', 'label' => __('Indirizzo', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'zona', 'class' => '', 'label' => __('Zona', 'woocommerce') ) );
woocommerce_wp_text_input( array( 'id' => 'contatti', 'class' => '', 'label' => __('Contatti', 'woocommerce') ) );
然后在681排

update_post_meta( $post_id, 'orario', stripslashes( $_POST['orario'] ) );
update_post_meta( $post_id, 'luogo_evento', stripslashes( $_POST['luogo_evento'] ) );
update_post_meta( $post_id, 'indirizzo', stripslashes( $_POST['indirizzo'] ) );
update_post_meta( $post_id, 'zona', stripslashes( $_POST['zona'] ) );
update_post_meta( $post_id, 'contatti', stripslashes( $_POST['contatti'] ) );
它保存我在产品页面中插入的数据。
我可以在single product.php中打印出来吗?

您可以执行以下操作:

echo get_post_meta(get_the_ID(), 'orario', true );
echo get_post_meta(get_the_ID(), 'luogo_evento', true );
echo get_post_meta(get_the_ID(), 'indirizzo', true  );
echo get_post_meta(get_the_ID(), 'zona', true  );
echo get_post_meta(get_the_ID(), 'contatti', true  );
我希望这有帮助