Title: Help with index page code
Last modified: August 19, 2016

---

# Help with index page code

 *  Resolved [coldsector](https://wordpress.org/support/users/coldsector/)
 * (@coldsector)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/help-with-index-page-code/)
 * Hello on the template i am using i have this code on the index page:
 *     ```
       <?php get_header() ?>
   
       <div id="container">
       <div id="content">
   
       <?php if (have_posts()) : ?>
       <?php query_posts('showposts=5'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="post" id="custom_frontpage_post">
       <h1 class="entry-title"><a>" title="<?php printf(__('Permalink to %s', 'sandbox'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h1>
       <div class="entry-date"><?php the_time('d M, Y'); ?></div>
       <div class="entry"><?php the_excerpt(); ?></div>
       <div class="readmore"><a>" title="<?php printf(__('Permalink to %s', 'sandbox'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark">Read More</a></div>
       </div>
       <?php endwhile; endif;?>
   
       	</div><!-- #content -->
       </div><!-- #container -->
       <?php get_sidebar() ?>
       <?php get_footer() ?>
       ```
   
 * With this i can show my most recent 5 posts, but i would like to have a “link”
   to go to older ones and from older go to recent ones, i have tryed this code:
 *     ```
       <div id="nav-below" class="navigation">
       				<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&laquo;</span> Older posts', 'sandbox')) ?></div>
       				<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&raquo;</span>', 'sandbox')) ?></div>
       				<div class="clearboth"></div>
       			</div>
       ```
   
 * But when i go to “older posts” it only shows the same 5 again, i think its because
   of the previous code i posted. Can anyone tell me how to solve this, make 5 posts
   appear in the first page with excerps and “read more” but also make “older posts”
   appear if you press the button.
 * I thank you all in advance for the help.

Viewing 1 replies (of 1 total)

 *  Thread Starter [coldsector](https://wordpress.org/support/users/coldsector/)
 * (@coldsector)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/help-with-index-page-code/#post-942259)
 * After some research i manage to fix this i leave here the code so it may help
   other with my problem.
 * The only thing i needed to make was changing this:
 *     ```
       <?php query_posts('showposts=5'); ?>
       ```
   
 * Into this:
 *     ```
       <?php query_posts('showposts=5'.'&paged='.$paged); ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Help with index page code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [coldsector](https://wordpress.org/support/users/coldsector/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/help-with-index-page-code/#post-942259)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
