WP_Query() does not return all entries

后端 未结 2 1325
旧巷少年郎
旧巷少年郎 2020-12-16 10:03

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



        
相关标签:
2条回答
  • 2020-12-16 10:11

    Try adding posts_per_page=-1 to the string of parameters passed to 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.

    0 讨论(0)
  • 2020-12-16 10:20
    $args = array(
        'post_type' => 'product',
        'orderby' => 'ASC',
        'posts_per_page'=>-1
    );
    $wp_query = new WP_Query($args);
    
    0 讨论(0)
提交回复
热议问题