2015-09-03 85 views
0

我已经添加了从定制文章类型与功能woocommerce产品管理选项卡,选择的能力在本教程中使用http://www.remicorson.com/mastering-woocommerce-products-custom-fields/woocommerce自定义管理标签打破

所以我添加了一个自定义字段

变化
woocommerce_wp_select(
    array(
    'id'  => '_circuit', 
    'label' => __('choose circuit', 'woocommerce'), 
    'options' => get_circuits_as_array() 
     ) 
    ); 

现在的功能看起来像这样

function get_circuits_as_array(){ 
     $args = array('post_type' => 'top', 'posts_per_page' => -1, 'post_status'=>'published'); 
     $loop = new WP_Query($args); 
     $circuits = array('0'=>'--wybierz opcję--'); 
     while ($loop->have_posts()) : $loop->the_post(); 
    setup_postdata($post); 
     $circuits[get_the_id()] = get_the_title(); 
     endwhile; 
     wp_reset_query(); 
     return $circuits; 
    } 

的问题是,在代码上传到服务器这一功能打破了变化取胜道琼斯指数只显示默认的“添加变化信息”

enter image description here

控制台显示没有错误。

我想这已经是与Ajax请求,但无法弄清楚到底是什么,我已经试运行get函数在其他文件等,但没有运气。

的woocommerce插件版本2.2.8是

回答

0

行,所以我已经想通了这一点,解决方法是使用具有$环 - >帖子foreach循环的阵列

function get_circuits_as_array(){ 
     $args = array('post_type' => 'top', 'posts_per_page' => -1, 'post_status'=>'published'); 
     $loop = new WP_Query($args); 
     $circuits = array('0'=>'--wybierz opcję--'); 
     foreach ($loop->posts as $circuit) { 
     $circuits[$circuit->ID] = $circuit->post_title; 
     } 
     wp_reset_query(); 
     return $circuits; 
    }