【发布时间】:2015-09-03 10:47:57
【问题描述】:
我在 woocommerce 产品管理选项卡中添加了从自定义帖子类型中进行选择的功能,该功能具有本教程中使用的功能http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
所以我添加了一个自定义字段
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;
}
问题在于,在将代码上传到服务器时,此函数会破坏变体窗口,它只显示默认的“添加变体消息”
控制台没有显示错误。
我猜这与 ajax 请求有关,但无法弄清楚究竟是什么,我试图将 get 函数移到其他文件等中,但没有运气。
woocommerce插件版本为2.2.8
【问题讨论】:
标签: php wordpress woocommerce