Title: &#8216;showposts&#8217; breaks WP_Query
Last modified: August 19, 2016

---

# ‘showposts’ breaks WP_Query

 *  [withinsight](https://wordpress.org/support/users/withinsight/)
 * (@withinsight)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/showposts-breaks-wp_query/)
 * When using WP_Query to setup multiple loops, if you attempt to pass showposts
   to limit the number of posts to display, the query to the database does not work
   properly. Examples:
 * **Category Queries**
    new WP_Query(‘category_name=mycat’); //works new WP_Query(‘
   category_name=mlb&showposts=5’); //showposts does nothing
 * **Author Queries**
    new WP_Query(‘author_name=myauth’); //works new WP_Query(‘
   author_name=myauth&showposts=1’); //showposts does nothing
 * In all these blocks of code I’m using a standard while loop, and I need to limit
   the data returned in the db query.

Viewing 1 replies (of 1 total)

 *  [CookiesForDevo](https://wordpress.org/support/users/actionnerd/)
 * (@actionnerd)
 * [16 years, 10 months ago](https://wordpress.org/support/topic/showposts-breaks-wp_query/#post-1062916)
 * I got it to work with a slightly different loop.
 *     ```
       <?php
           $recentPosts = new WP_Query();
           $recentPosts->query('meta_key=Quote&showposts=1&orderby=rand');
       ?>
       <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
       ```
   
 * Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘‘showposts’ breaks WP_Query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [CookiesForDevo](https://wordpress.org/support/users/actionnerd/)
 * Last activity: [16 years, 10 months ago](https://wordpress.org/support/topic/showposts-breaks-wp_query/#post-1062916)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
