6

製品用のカスタム メタ ボックスをいくつか作成しました。

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 で印刷できますか?

4

1 に答える 1

9

次のようにします。

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

これが役立つことを願っています!

于 2013-11-26T16:40:43.577 に答える