为了加快查询速度,我使用以下参数:
$args = array(
\'post_type\' => \'product\',
\'fields\' => \'ids\',
);
$query = new WP_Query($args);
虽然这确实会像预期的那样返回一个ID数组,但我不断得到多个Trying to get property of non-object in /wp-includes/query.php
通知。即使我身体里什么都没有,这种情况也会发生while
除了the_post()
:if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
endwhile;
endif;
是的the_post()
这是什么原因?知道我为什么收到这些通知吗?