Title: Limit While have_posts to 3 posts
Last modified: August 19, 2016

---

# Limit While have_posts to 3 posts

 *  Resolved [anderskitson](https://wordpress.org/support/users/anderskitson/)
 * (@anderskitson)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/limit-while-have_posts-to-3-posts/)
 * For the code below how would I limit the amount of posts shown to 3?
    **UPDATE
   Found what I needed to do I needed to add this line _<?php query\_posts(‘posts\
   _per\_page=1’);?>_my while loop.
 *     ```
       <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
       <? if ($post->ID != $featured_ID) { ?>
       <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       <small>on <?php the_time('M d'); ?> in <?php the_category(', '); ?> tagged <?php the_tags(''); ?> by <?php the_author_posts_link(); ?></small>
       <?php the_excerpt(); ?>
       <div class="separator biggap"></div>
       <? } ?>
       <?php endwhile ?>
        <?php endif; ?>
       ```
   

The topic ‘Limit While have_posts to 3 posts’ is closed to new replies.

## Tags

 * [have_posts()](https://wordpress.org/support/topic-tag/have_posts/)
 * [limit](https://wordpress.org/support/topic-tag/limit/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [anderskitson](https://wordpress.org/support/users/anderskitson/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/limit-while-have_posts-to-3-posts/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
