title: How do I limit the Number of Posts to 3 for a Custom Post Type Query?
body: <p>I am trying to display results of a custom post type on my main wordpress page.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>                &lt;?php
  wp_reset_query();
  $args=array(
    'post_type' =&gt; 'rooms',
    'post_status' =&gt; 'publish',
    'caller_get_posts'=&gt; 1
  );
  $my_query = null;
  $my_query = new WP_Query($args);
  if( $my_query-&gt;have_posts() ) {  ?&gt;
      &lt;TABLE border="1" cellspacing="50"&gt;
      &lt;TR&gt;FEATURED ACTIVE LISTINGS&lt;/tr&gt;
    &lt;?php
    while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); 
      $my_custom_fields = get_fields(get_the_ID());
      if(isset($my_custom_fields['availability']) &amp;&amp; $my_custom_fields['availability'] == 'Available'):
  ?&gt;
  
      &lt;tr&gt;&lt;td&gt;&lt;?php echo the_post_thumbnail('thumbnail');?&gt;
      &lt;br&gt;UNIT &lt;?php echo the_field('unit_number'); ?&gt; &lt;?php echo the_field('bedrooms'); ?&gt;BEDS/&lt;?php echo the_field('bathrooms'); ?&gt;BA
      &lt;br&gt;$&lt;?php echo the_field('price'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;?php 
  endif;
  endwhile; ?&gt;
    &lt;/TABLE&gt;
  &lt;?php }
  wp_reset_query();
  ?&gt;
  </code></pre>
  
  <p>This works. However, If I try to add <code>'posts_per_page' =&gt; 3,</code> into the array of args. It does not display any results at all. What am I doing wrong, or is there an alternative way to achieve this same result?</p>
  
  <p>If it is relevant, The plugins I am using are Advanced Custom Fields and Custom Post Types. </p>
  
  <p>Thanks in advance!</p>
  
  <p>SOLVED:</p>
  
  <p>I have actually figured it out myself, and thought I would share how I solved it.</p>
  
  <p>'posts_per_page' => 3 was working but it would only show the last 3 posts of that type that was NOT being filtered by if(isset($my_custom_fields['availability']) &amp;&amp; $my_custom_fields['availability'] == 'Available'):</p>
  
  <p>In order to Limit posts that were being filtered by this field, I added my own counter and set it to be at max of 3. I changed the above line to if(isset($my_custom_fields['availability']) &amp;&amp; $my_custom_fields['availability'] == 'Sold' &amp;&amp; ($postcount &lt; 3)): and added $postcount++; inside the loop.</p>
  
  <p>Thanks again for your help. I hope this helps whoever else.</p>