• I am trying to use multiple loops on a single post page and when I try to use pagination the pages all link back to the single post page.

    For example i have the usual loop in the single.php file:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    Then below that I have another loop to simply display the latest posts:

    <?php
    if (is_single()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged");
    }
    ?>

    The latest posts display fine. I have it set to show 30 posts before it pages. The pagination shows up fine at the bottom but the links all point back to the single post page. I am using the WP-PageNavi plugin but cant tell if that is causing the problem. Anyone know a way to get the page links to link correctly?

Viewing 2 replies - 1 through 2 (of 2 total)
  • the pages all link back to the single post page

    I’m not really sure what you mean…?

    Do you mean that all the links on that page just link back to where you are? Thats because you’ve used single.php to do this in…and that is used to display a single post usually. If you haven’t got the code in single.php to display a single post, but the loop, then the loop is going to display, not the post…

    Do you have a link for us to look at?

    Thread Starter trapmuzik

    (@trapmuzik)

    I think i know what the problem is. But yes I am using single.php with two loops in it. The first to show the single post and the second to show snippets of the latest posts right underneath it.

    Do you mean that all the links on that page just link back to where you are?

    Yes and I think this is because I am using the get_query_var(‘paged’) query which is apparently returning the single page I am on so all the pagination links link back to the single post page (i.e. url.com/content/singlepost.html/page/2 and so on). So of course when i click on these links I get returned right back to the same single post page. So I think the fix would be to set paged variable to the front page if thats possible. Does that sound about right? Sorry for the lack of a link but the site is a little nsfwish..lol

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple loops with pagination on single post page’ is closed to new replies.