Changing the Number of Post on Different Pages

I ran into a bit of a mind game yesterday while working on another site. In WordPress options, under reading, you can set how many post per page you’d like to see. The site I was working on I wanted only one post on the front page. So I change the option to 1 and check my pages, realizing I have 2 problems. Problem 1 there are still 4 post on the front page, problem 2 there is only 1 post per page on the archive pages. What the Heck??

So I wanted 1 post on the front page and many (at least 5) post on the archive pages, how do I fix this? After doing some digging into the templates code I was using I find this at the top of the index.php

<?php query_posts('showposts=4'); ?>

Sweet, this explains my 4 post on the front page, but it also fixes my problem, I can now set the number of post manually to 1 and set the option site wide to 5 or more, which will fix my archive and sitemap pages.

I just tested it and it works across many other templates, which means it’s part of wordpress and not something the designer of the template created.

If adding it to your site remember to add to your index.php or main.php right above…

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

Technorati Tags:


2 Comments to “Changing the Number of Post on Different Pages”

  1. Chris 28 March 2007 at 7:39 pm #

    Here’s a plugin that’ll help with that (and more). It’s bailed me out more than once. 🙂

  2. Richard Curry 29 March 2007 at 12:12 am #

    thanks for the heads up, i’ll have to d/l it and check it out

Leave a Reply