• Hey everyone,

    I am working on the pagination for my from scratch word press theme.

    You can see the result of the code at the bottom, but above the footer.
    ergonomicchair.org.customers.tigertech.net/page/2/
    (admin, please do not change this to a link, I do not want it to be indexed by Google)

    Here is the code:

    <?php the_excerpt(); ?>
    </div>
    </div>
    <?php endwhile;
    kriesi_pagination();
    next_posts_link('<< older entries');
    previous_posts_link('newer entries >>');
    else :
    ?>

    When you click on the pagination below (either the numbered pagination or older/newer entries), you go to a /page/2/ or /page/3/ etc, the post are always the newest couple of posts.

    Why is this happening? How do I get it to show the next few posts on different pages, say /page/4/ ?

    When I switch back to the 2011 theme, pagination works fine in those themes.

    Am I missing the file it is trying to access?? Any ideas?

    thanks,
    Evan

Viewing 8 replies - 1 through 8 (of 8 total)
  • Does this template use a custom query?

    Do you have any custom queries on the site?

    http://codex.wordpress.org/Function_Reference/query_posts#Pagination
    If so, you need to account for pagination in the query

    Thread Starter solid28

    (@solid28)

    Hey Voodoo & esmi, thanks for the quick responses. I looked at the link and see that query_posts will likely solve my issue.

    Previously I only had the ‘query_posts( ‘posts_per_page=4′ );’

    Now I have:

    query_posts( array( 'cat' => 8, 'paged' => get_query_var('paged')) );
    query_posts( 'posts_per_page=4' );
    if (have_posts()) :
    while (have_posts()) : the_post();?>
    <div class="blog-post-preview">

    I don’t know if it is proper to put to query_posts together in a row, but when I commented out the ‘query_posts( ‘posts_per_page=4′ );’, then it said “no posts to display”

    The code above does not show different posts on different pages.

    How should I proceed? Do I need to use something like

    global $query_string;
    query_posts( $query_string . '&order=ASC' );

    thank you so much,
    Evan

    Try:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 8,
    	'posts_per_page' => 4,
    	'paged' => $paged
    );
    query_posts($args);
    if (have_posts()) :
    [etc]

    `

    Thread Starter solid28

    (@solid28)

    that one resulted in “no posts found”

    Hmmmm…is the problem that it’s on index.php that I have this code?

    No – the code will work in any template file – assuming you have a category with the id of 8.

    Thread Starter solid28

    (@solid28)

    esmi, the issue was mine…I wanted to show posts for any category and I have no posts in category 8…I just copied and pasted from the example on the codex page >_<

    I removed the parameter ‘cat’ and it worked fine.

    Do you know of a page that lists all the query_posts parameters? Do u think this one is the best ?http://codex.wordpress.org/Function_Reference/query_posts

    Thank you so much,
    Evan

    The best reference page (with examples) for query_post parameters is http://codex.wordpress.org/Function_Reference/WP_Query

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Help With Pagination’ is closed to new replies.