WordPress: posts_per_page in archive.php causing 404 error

I’m trying to control the number of posts listed by the archive.php template using the following query_posts function before the loop:

<?php query_posts('posts_per_page=1'); ?>
<?php <?php  if (have_posts()) : while (have_posts()) : the_post(); ?>

This query_posts setup doesn’t work in archive.php the same way it does for index.php: it will in fact display one post, but clicking on previous posts points me to the 404 error template.

Read More

I’ve looked elsewhere on the web and on StackOverflow for solutions, but have not been able to find a anything that works. I’ve also tried the following without success:

<?php global $query_string; query_posts($query_string . '&posts_per_page=1&paged=' . $paged); ?>

and

<?php global $query_string; query_posts($query_string . '&posts_per_page=1'); ?>

Related posts

Leave a Reply

2 comments

  1. 1) Login as the admin in WordPress.

    2)Go to the Settings tab.

    3)Go to the Reading tab.
    4)Change the Blog pages show at most from the default 10 to any number *less than 10.
    For example, 5.

    5)Save the changes.

    View the blog.

    edit the number to less than 10, hope it helps you out. It fixed mine.

    while debugging i found out that default posts per page option should be less than any custom posts_per_page in query_posts function. That’s all. Weird, but that’s the fact.