• I just realized that the theme I’m using for my blog doesn’t have the “Older Posts” and “Newer Posts” links at the bottom of the page that allow people to get to the older posts that I created.

    I was told that I needed to add the below code to my index.php file, which I did, but the links still aren’t showing up.

    <?php next_posts_link(‘Older Posts’); ?>
    <?php previous_posts_link(‘Newer Posts’); ?>

    Did I need to do more than just simply paste the above code in the bottom of my index.php file?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Did I need to do more than just simply paste the above code in the bottom of my index.php file?

    Yes; you need to paste that code in the correct place within your template file.

    The links need to go outside the Loop, specifically, outside of the while( have_posts() ) part of the Loop.

    Thread Starter agfreesafety

    (@agfreesafety)

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

    Thread Starter agfreesafety

    (@agfreesafety)

    Sorry for posting all of that, I was just trying to show that I placed the code at the end, which I believe meets your specification of it being outside of that loop.

    The loop you’re speaking of is way at the beginning of the index.php (which I pasted above). Please let me know if you see something I did wrong. And thanks for your time.

    It looks like you pasted the code outside of the document body. Try putting it where the wp_pagenavi() function call is.

    Thread Starter agfreesafety

    (@agfreesafety)

    I’m sorry, I don’t know anything about PHP, would you be so kind as to tell me where exactly the code should be placed? Please bear with me.
    Below is what I have near the wp_pagenavi() function call.

    Should I paste them both before the </div> tag right before the “Page Number” commented line?

    <script src=”http://pastebin.com/embed_js.php?i=UcWwTb0Y”></script&gt;

    Thread Starter agfreesafety

    (@agfreesafety)

    I was trying to paste the section of my code above using Pastebin, but I don’t know how to use pastebin yet, obviously.

    Replace this:

    <div class="pagenavi">
    <?php if( function_exists( 'wp_pagenavi ' )) { wp_pagenavi(); } ?>
    </div>

    With this:

    <div class="pagenavi">
    <?php if( function_exists( 'wp_pagenavi ' ) ) {
         wp_pagenavi();
    } else {
         next_posts_link('Older Posts');
         previous_posts_link('Newer Posts');
    } ?>
    </div>

    you pretty much succceeded with the pastebin.

    click the pastebin link http://pastebin.com/;
    paste your code into the large field;
    select ‘syntax highlighting’ , for instance ‘PHP’;
    click ‘submit’;
    copy the new address in the top browser address bar;
    post this url here.

    Should I paste them both before the </div> tag right before the “Page Number” commented line?

    yes

    Thread Starter agfreesafety

    (@agfreesafety)

    Got it working now, fellas. Thanks so much!

    I’m having the same problem. I tried pasting the code above in my index.php file, but it’s not working. I pasted my index.php file in pastebin and here’s my URL: http://pastebin.com/u9CFr5xx

    Does anyone know where I put these codes at?
    <?php next_posts_link(‘Older Posts’); ?>
    <?php previous_posts_link(‘Newer Posts’); ?>

    Nevermind, everyone. I had my settings off. Fixed the problem.

    I am using 3.2.1 + K2 theme & I’m not sure in which file I should add this code?

    Can anyone tell me where to put the ‘older/newer’ posts (at the bottom) code? Do I make a /local file so the original can be updated OK?

    Thank you in advance,
    Nico Morrison
    London UK

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How Do I Add "Older Posts" and "Newer Posts" Links to my Blog?’ is closed to new replies.