• Hello – I’ve checked through the forums for solutions, and tried a number of them without much luck, so I’m posting for some advice on how to fix this.

    I’ve installed WP on an internal server, and am customizing a template to display all posts with five posts displaying per page. The problem is that even though there are a total of 25 posts loaded and published, only the first five appear – the “previous posts” link at the bottom only takes me to “page 2”, but with the same five posts from “page 1” displayed.

    Here is the pertinent code from the template:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    I tried resetting the query after the loop, but I’m still getting the same five posts as on the front page. Are there any obvious problems with the loop? Any assistance would be greatly appreciated.

    With thanks,

    Jack Cole

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter iridium312

    (@iridium312)

    Here is the code:

    https://pastebin.com/w37JT8B9


    Jack

    Moderator keesiemeijer

    (@keesiemeijer)

    try to set the $paged variable:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=$blogpage_cats.&paged=$paged");

    Thread Starter iridium312

    (@iridium312)

    Thanks, but unfortunately it’s still giving me the same five posts on Page 2, 3, etc.

    I’m thinking I don’t even need the category selection part of the query, so, if that’s the case, is there a way to re-write the query fetch more simply?

    Thank you for your assistance so far, Keesiemeijer.

    Jack

    Moderator keesiemeijer

    (@keesiemeijer)

    If you don’t need the category selection remove the whole query:

    <?php
            if (get_option('blogpage_cats') <> ''){
                    $blogpage_cats = implode(",", get_option('blogpage_cats'));
            }
            query_posts("cat=$blogpage_cats.&paged=$paged");
    ?>

    The string in query_posts() has an extra period in it. It should be one of the following:

    query_posts( "cat=$blogpage_cats&paged=$paged" );

    or

    query_posts( 'cat=' . $blogpage_cats . '&paged=' . $paged );

    Thread Starter iridium312

    (@iridium312)

    Thanks to you both. I edited the query as Big Bagel suggested (no luck – still same five posts on every page), and finally ended up removing the query_posts() block altogether (also no luck).

    I decided to go through and clean up what I had just to see if it made a difference. I didn’t catch any other obvious flaws, but I’m sure I missed something. No matter what I do it seems to show the last five posts on the front page, then when I click “Previous Posts”, the URL changes to ../page/2 but shows the exact same five posts.

    Here is the cleaned-up code.

    Any advice or direction is greatly, greatly appreciated.


    Jack

    Try these. Maybe one will work happily:

    query_posts( array( 'paged' => get_query_var( 'page' ) ) );

    or

    global $query_string;
    query_posts( $query_string );

    If any of these get pagination to work, then you can then try adding back in your category argument.

    Thread Starter iridium312

    (@iridium312)

    Thank you again, Big Bagel. I think I’ve traced the problem to the template itself – the pagination (including your queries above!) worked as expected when I switched from the template I was using to Twenty Ten or Twenty Eleven.

    I really appreciate you and keesiemeijer taking the time and effort to look at the code!


    Jack

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Pagination Broken :: Nothing Seems to Work’ is closed to new replies.