WordPress.org

Ready to get started?Download WordPress

Forums

Have pagination limited to 1 post per page (2 posts)

  1. jmwhite19
    Member
    Posted 2 years ago #

    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

  2. jmwhite19
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic