Title: WP_Query  only returns 10 items
Last modified: August 30, 2016

---

# WP_Query only returns 10 items

 *  Resolved [rbryant4](https://wordpress.org/support/users/rbryant4/)
 * (@rbryant4)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wp_query-only-returns-10-items/)
 * Hey everyone–having a slight issue: my WP_Query() function is only returning 
   10 pages and/or posts even though there are many more. I can’t figure it out!
 *     ```
       $my_wp_query = new WP_Query();
       $all_wp_pages = $my_wp_query->query(array('post_type' => 'page');
       for ($r = 0; $r < count($all_wp_pages); $r++){
       echo ' <!--'. print_r($all_wp_pages[$r])  .'-->';
       }
       ```
   
 * Here’s a snippet of code where I’m getting the issue–It’s only returning the 
   10 LATEST posts or pages made. If I make a new ‘page’ then it will be returned
   at the top of the returned list, but the oldest one in the list will get pushed
   out and not be in the list anymore. I’m super confused why this is happening.
 * Thanks guys!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [rbryant4](https://wordpress.org/support/users/rbryant4/)
 * (@rbryant4)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wp_query-only-returns-10-items/#post-6611692)
 * To illustrate:
 * I have 9 example pages that WP_Query returns on ‘post_type’ => ‘page’
 * CURRENT
    Site Pages (9) pages total ——- Page 9 Page 8 Page… Page 2 Page 1 END
   LIST
 * AFTER ADDING
    one new page (10) pages total ——- START RETURNED LIST Page 10 Page
   9 Page… Page 2 Page 1 END LIST
 * AFTER ADDING
    2 new pages (11) ——- START RETURNED LIST Page 11 Page 10 Page… 
   Page 3 Page 2 END LIST
 *  Thread Starter [rbryant4](https://wordpress.org/support/users/rbryant4/)
 * (@rbryant4)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/wp_query-only-returns-10-items/#post-6611695)
 * I figured it out-FINALLY. Apparently I needed to add:
 * ‘posts_per_page’=> -1
 * to my WP_Query() arg list. The default–which I still don’t know where it’s set–
   was apparently 10. This overrides it.
 * Everything is working again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP_Query only returns 10 items’ is closed to new replies.

## Tags

 * [pages](https://wordpress.org/support/topic-tag/pages/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [troubleshooting](https://wordpress.org/support/topic-tag/troubleshooting/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 1 participant
 * Last reply from: [rbryant4](https://wordpress.org/support/users/rbryant4/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/wp_query-only-returns-10-items/#post-6611695)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
