Php WP_查询时显示空白页

Php WP_查询时显示空白页,php,woocommerce,wordpress,Php,Woocommerce,Wordpress,我想通过WP_Query()从WooCommerce获得所有订单 但这段时间还没有结束,我得到了一张空白页 租金查询: $type = 'shop_order'; $args = array( 'post_type' => $type, 'post_status' => 'any', 'posts_per_page' => -1, );

我想通过WP_Query()从WooCommerce获得所有订单

但这段时间还没有结束,我得到了一张空白页 租金查询:

        $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)在
中这里,而($The_query->have_posts())
,您没有将函数
放入
。也许用它可以解决你的问题

//here comes the blank page
while ( $the_query->have_posts() ) {
    the_post(); // add it
}

你在这段时间内真的输出了什么吗?(我知道这很明显,但最好问一下)嗨,thx,但我找到了另一个解决方案,我把这个问题弄错了,而不是
the_post()
,它应该是
$the_query->the_post()