[英]WP_Query while shows blank page
我想通过WP_Query()从WooCommerce获取所有订单
但是虽然没有结束,但我的空白页面ourrent查询:
$type = 'shop_order';
$args = array(
'post_type' => $type,
'post_status' => 'any',
'posts_per_page' => -1,
);
$the_query = new WP_Query( $args );
var_dump($the_query); //This Showes something
if ( $the_query->have_posts() ) {
//here comes the blank page
while ( $the_query->have_posts() ) {
}
}
wp_reset_postdata();
var_dump($ the_query)在这里http://laravel.io/bin/KmwlK
在while ( $the_query->have_posts() )
,您没有放置函数the_post()
。 也许使用它可以解决您的问题。
//here comes the blank page
while ( $the_query->have_posts() ) {
the_post(); // add it
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.