Title: Query posts shows only 2 posts
Last modified: August 22, 2016

---

# Query posts shows only 2 posts

 *  [Stef Verbeeck](https://wordpress.org/support/users/twizted/)
 * (@twizted)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/query-posts-shows-only-2-posts/)
 * Hi all!
 * On a site I’m building, I’m trying to display all posts in the custom type “clients”
   in the custom category “casestudy” on top of the page, and all other (non case
   study) posts below.
 * I use two queries. The second one with all posts works just fine, but the first
   one only shows the two latest posts. This is the code used:
 *     ```
       <?php
       query_posts('post_type=clients&cat=19'); // load ony the case studies category
       while ( have_posts() ) : the_post();
       ?>
   
       <div class="client_column"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>
   
       <?php endwhile; ?>
       <?php wp_reset_query(); ?>
       ```
   
 * What am I doing wrong? I’ve been building WP sites for over 5 years now, and 
   never encountered this problem. I’ve flushed the permalinks cache, triple checked
   if necessary posts are in the right category and made sure the default amount
   of posts in settings is set to 20.
 * Any help would be very much appreciated.

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/query-posts-shows-only-2-posts/#post-5711002)
 * review [http://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts](http://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts)
 * also try to add the ‘posts_per_page’ parameter directly into the query.
 * do you get any error messages from the loop?
    [http://codex.wordpress.org/Debugging_in_WordPress](http://codex.wordpress.org/Debugging_in_WordPress)
 *  Thread Starter [Stef Verbeeck](https://wordpress.org/support/users/twizted/)
 * (@twizted)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/query-posts-shows-only-2-posts/#post-5711035)
 * Thanks Alchymyth!
 * That worked like a charm. My code now looks like this:
 *     ```
       <?php
       $args = array( 'posts_per_page' => 20, 'post_type'=> 'clients', 'category' => 19 );
   
       $myposts = get_posts( $args );
       foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
       	<div class="client_column">
          		<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
       	</div>
       <?php endforeach; wp_reset_postdata();?>
       ```
   
 * Thx for your help.

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

The topic ‘Query posts shows only 2 posts’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [number](https://wordpress.org/support/topic-tag/number/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [two](https://wordpress.org/support/topic-tag/two/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Stef Verbeeck](https://wordpress.org/support/users/twizted/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/query-posts-shows-only-2-posts/#post-5711035)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
