添加图像加载器WooCommerce产品自定义字段

时间:2015-12-15 12:50:11

标签: javascript php wordpress image woocommerce

我已将此代码粘贴到我的主function.php中,效果很好 但我想在我的woocommerce产品中添加一个图像,我不知道如何实现这一目标。有没有人有这样做的想法?

function woo_add_custom_general_fields() {

global $woocommerce, $post;

 woocommerce_wp_text_input(
 array(
'id' => 'telnr',
'label' => __( 'Nr. Tel)', 'woocommerce' ),
'placeholder' => 'Nr',
'desc_tip' => 'true',
'description' => __( 'tel nr.', 'woocommerce' )
     )
  );
}

function woo_add_custom_general_fields_save( $post_id ){

 $woocommerce_telnr = $_POST['telnr'];
if( !empty( $woocommerce_telnr ) )
 update_post_meta( $post_id, 'telnr', esc_html( $woocommerce_telnr ) );

}

这是我尝试过的,但失败了:

function woo_options_add($options) {

// This is a option heading
$woo_metaboxes = array(

    "image" => array (
        "name" => "image",
        "label" => "Post Image",
        "type" => "upload",
        "desc" => "Upload file here…"
    )),

// Return new options
return $options;

}

0 个答案:

没有答案