Support » Fixing WordPress » Have pagination limited to 1 post per page

  • I’m trying to achieve the following situation:

    I have a blog that has only one post on the frontpage. I want to be able to create pagination for the index.php so that one post is displayed on each page. The archives and other areas can use the standard settings in the Settings menu.

    After much playing around I’ve managed to get 90% of the way there. Each post appears on its on page through /page/1, /page/2 etc etc but the “Older Entries” pagination link doesn’t work. The “Newer Entries” links does, but the pagination never generates the link to go back, only forward.

    Here is the code I’m using on the index.php at the moment:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("posts_per_page=1&paged=$paged");
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <!-- Post layout here -->
    
    <?php endwhile; ?>
    
    <?php else : ?>
    
    <h2>Not Found</h2>
    
    <?php endif; ?>

    Is there anyway I can achieve this with working pagination?

    Thanks,

    James

Viewing 1 replies (of 1 total)
  • Thread Starter jmwhite19

    (@jmwhite19)

    Actually turns out I was trying to use the pagination code outside of the loop hence the strange pagination behavior. The code above works fine.

Viewing 1 replies (of 1 total)
  • The topic ‘Have pagination limited to 1 post per page’ is closed to new replies.