WP_Query()不返回所有条目。

时间:2023-02-05 00:17:58

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

我有这个查询,它只返回我在表上的一些条目。我有超过10篇文章,但是这个查询只返回6。请帮助建议

$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();

2 个解决方案

#1


82  

Try adding posts_per_page=-1 to the string of parameters passed to WP_Query.

尝试将posts_per_page=-1添加到传递给WP_Query的参数字符串。

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.

如果没有设置该值,那么它将返回使用在设置>>中设置的每个页面的默认文章选项,读取>>博客页面最多显示一次。

My guess is that this value is 6 so its returning that many posts since you did not specify a different limit.

我的猜测是这个值是6,所以它返回了很多帖子,因为您没有指定不同的限制。

#2


12  

$args = array(
    'post_type' => 'product',
    'orderby' => 'ASC',
    'posts_per_page'=>-1
);
$wp_query = new WP_Query($args);

#1


82  

Try adding posts_per_page=-1 to the string of parameters passed to WP_Query.

尝试将posts_per_page=-1添加到传递给WP_Query的参数字符串。

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.

如果没有设置该值,那么它将返回使用在设置>>中设置的每个页面的默认文章选项,读取>>博客页面最多显示一次。

My guess is that this value is 6 so its returning that many posts since you did not specify a different limit.

我的猜测是这个值是6,所以它返回了很多帖子,因为您没有指定不同的限制。

#2


12  

$args = array(
    'post_type' => 'product',
    'orderby' => 'ASC',
    'posts_per_page'=>-1
);
$wp_query = new WP_Query($args);