I can understand why WordPress doesn’t build in this functionality, after all, they can only do so much and they rely on the community to created plugins for this kind of thing, but I don’t understand why nobody has created a simple plugin to allow WordPress users to specify that they want a different number of posts to display on the homepage than on the archives or category pages. Well, I correct myself, some guy in Nepal has created a plugin, but he requires you to join his email list in order to use it which results you getting spammed on a regular basis. That’s a plugin I can do without. But I figured out how to put in a tiny bit of code that does exactly what I want it to.
My solution may not work for you, but maybe it will point you in the right direction. First off, I’m using the redoable theme, so I’m not sure whether this applies to other themes as well although I think there’s a good chance it will or that if it’s not identical you’ll be able to figure it out.
My situation was that I wanted to display 10 posts on the homepage, but in each of my categories I wanted to display all the posts. However, I have tested this and you can also use this code to specify the exact number of posts to display in your categories.
What I did was I found the code <?php include (TEMPLATEPATH . ‘/theloop.php’); ?> in the file /wp-content/themes/redoable/archive.php and changed it to be <?php query_posts($query_string.’&posts_per_page=-1′); include (TEMPLATEPATH . ‘/theloop.php’); ?>. The value “-1″ means all your posts in that category will show up. If you want to limit it to 20 you would replace “-1″ with “20″.
That’s it, piece of cake. Because this code is only included in the archive.php page it will have no effect on your homepage. If someone else tries this out with other themes and it works or doesn’t please post your comments here so others can benefit. It took me hours and hours of searching to figure this out, so I’m sure there are plenty of others looking for it too and becoming just as frustrated as I did.