WP_Query()不会返回所有条目 [英] WP_Query() does not return all entries
问题描述
我有此查询,该查询仅返回表上我拥有的一些条目.我有10多个帖子,但此查询仅返回6.请提供帮助
I have this query that returns only a few of the entries I have on the table. I have over 10 posts but this query only returns 6. Please help with suggestions
$query = new WP_Query("year=2011&monthnum=09&post_status=publish&post_type=post&orderby=post_date&order=DESC");
while ($query->have_posts()):
$query->the_post();
$title=get_the_Title();
echo"<p><input type=\"checkbox\" name=\"MyArticle[]\" value=\"".get_the_ID()."\">".get_the_Title()."</p>";
endwhile;
wp_reset_query();
推荐答案
尝试将posts_per_page=-1
添加到传递给WP_Query
的参数字符串中.
Try adding posts_per_page=-1
to the string of parameters passed to WP_Query
.
如果未设置该值,则使用在Settings >> Reading >> Blog pages show at most
中设置的默认每页默认帖子数.
If that value is not set, then it falls back to use the default posts per page option you have set in Settings >> Reading >> Blog pages show at most
.
我的猜测是该值是6,因此由于您未指定其他限制,它返回的帖子数量很多.
My guess is that this value is 6 so its returning that many posts since you did not specify a different limit.
这篇关于WP_Query()不会返回所有条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!