WP_Query()不会返回所有条目 [英] WP_Query() does not return all entries

查看:116
本文介绍了WP_Query()不会返回所有条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此查询,该查询仅返回表上我拥有的一些条目.我有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆