• Hey all, I am working on a WordPress theme. The site I am posting on for now is right here.

    I am finding that when I scroll down on the main page and click “<< Older posts,” nothing is happening. The address changes to “(website)/?paged=4,” but all the posts on the page are the same.

    Any idea why this might be going on?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Please paste all the code from the theme template file (probably index.php) that is displaying those posts into a pastebin, such as wordpress.pastebin.ca, and report the link back here. Maybe someone might spot your problem. Thanks.

    Do you have enough posts for page 2 and beyond? Set your post display to 2 per page (under admin/reading) or so and see if pagination works.

    Thread Starter youreviltw1n

    (@youreviltw1n)

    Thanks for getting back to me!

    Songdog, I have like a bajillion posts of gibberish on the site, so it should definitely be able to pull something in. I set up the reading options to display only 2 per page and it still wouldn’t show any back log.

    Michael, here is my index code: https://wordpress.pastebin.ca/1595592

    The older posts works fine in the archives and under categories, so maybe it has something to do with the 2 loops on the index page?

    Hard to tell… but might try this…change this:

    <?php query_posts(array('post__not_in' => $ids)); while (have_posts()) : the_post(); ?>

    to this:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts(array('post__not_in' => $ids,'paged'=>$paged)); while (have_posts()) : the_post(); ?>

    Thread Starter youreviltw1n

    (@youreviltw1n)

    Thanks for the help, Michael, but it didn’t look like that made a difference. The only thing that changed is that when I click on the “<< older posts” the address always goes to “(website)/?paged=2,” wherein with the old code, the page numbers had no limit.

    What two loops do you have on index? You need to run a new WP query to run a loop inside the main loop so they don’t crash into each other. I run mutliple new queries on a page that don’t conflict. See multiple loops. Maybe that’s the issue….

    Thread Starter youreviltw1n

    (@youreviltw1n)

    I think I do that. I start the second loop with:

    <?php rewind_posts(); ?>
    
    <?php query_posts(array('post__not_in' => $ids)); while (have_posts()) : the_post(); ?>

    If you look at my index page without any of the CSS or info pulling in the excerpts or post authors I think the loop PHP is:

    <?php query_posts('showposts=1'); $ids = array(); while (have_posts()) : the_post(); $ids[] = get_the_ID(); ?>
    
    <?php endwhile; ?>
    
    <?php rewind_posts(); ?>
    
     <?php query_posts(array('post__not_in' => $ids)); while (have_posts()) : the_post(); ?>
    
    <?php endwhile; ?>

    rewind_posts should work, but maybe try a new query, something like this format for the second loop (not sure if this actual example will work):

    <?php $my_query = new WP_Query(array('post__not_in' => $ids)); while ($my_query->have_posts()) : $my_query->the_post(); ?><?php endwhile; ?>
    Thread Starter youreviltw1n

    (@youreviltw1n)

    Song, it doesn’t look like that worked either. I don’t really know php, so I am just closing my eyes and cutting and pasting things. Maybe I’ll take a look into this later in the future.

    Thanks for all your help everyone.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘“Older Posts” not showing older posts’ is closed to new replies.