2013-11-26 31 views
4

我爲產品創建了一些自定義元框。如何獲得自定義元框的價值

在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中打印出來嗎?

回答

7

你會做到以下幾點:

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 ); 

我希望這有助於!

+0

簡單..謝謝! – dan

+0

沒問題,很高興我能幫忙:) – danyo