WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] problems w next_post and previous_post in almost spring (8 posts)

  1. Lori
    Member
    Posted 8 years ago #

    Hi,
    I love the Almost Spring template, but before I start tweaking it I need to find out if the navigation options work. I'd like to put next_post and previous_post links at the top of all but the index page, but no matter what I try I can't get it to work at all. On another blog I have (based on the "classic" theme), it was easy to get working, but with Almost Spring I can't get any links to show no matter what I try -- I've tried most of the alternatives here:
    http://codex.wordpress.org/index.php?title=Template_Tags/Previous_post&redirect=no

    The problem blog is here:
    http://www.textworkshop.com/wp1/index.php

    Massively grateful for any help or advice.

    (I would post my code here, but this is my first time posting here, and I'm not sure what "backticks" are. There's no preview function so I'm worried that it would look horrible...)

    Thanks,
    D

  2. moshu
    Member
    Posted 8 years ago #

    Just go back to the Codex page you linked to and read aloud (3 times) the Description section.

  3. Lori
    Member
    Posted 8 years ago #

    Thanks for looking in so quickly, Moshu. From that page it seems like I was barking up the wrong tree with next_post() etc.

    I'm not sure I've been able to explain what I actually wnat to do. If I want to have something like

    << previous post | home | next post >> at the top of individual post pages, which template tags should I use, and where should I put them?

    As an experiment I tried putting this

    <div style="text-align:center;">
    <?php posts_nav_link(' · ', 'previous page', 'next page'); ?>
    </div>

    after this
    <div class="post" id="post-<?php the_ID(); ?>">

    in index.php

    But nothing shows up...

    Apologies in advance for extremely ugly code...

    D.

  4. moshu
    Member
    Posted 8 years ago #

    "individual posts" are NOT displayed by the index.php, unless your theme is lacking all the additional template files.
    (see Template Hierarchy > http://codex.wordpress.org/Template_Hierarchy )

    The single post view - as we call it - usually is displayed by using the (surprize!) single.php template file.
    That's the one you want to edit.

    (Note. Classic doesn't have any additonal template files, that's why it worked editing the index :)

  5. Ryan Fitzer
    Member
    Posted 8 years ago #

    I haven't tested this but it's a good place to start:

    <div class="post_nav">
    <?php next_posts_link('&laquo; Previous Entries | ') ?><a href="<?php echo get_settings('home'); ?>/">Home</a><?php previous_posts_link(' | Next Entries &raquo;') ?>

    </div>

    There is currently nothing on the page that the codex search returns when you search for these tags but I pulled from the default theme. I did change the html a bit so they all stay on the same line. Let me know if it works for you.

  6. Lori
    Member
    Posted 8 years ago #

    Thanks a lot! That really helped and I'm on the right track now. :-)

    D.

  7. moshu
    Member
    Posted 8 years ago #

    Ryan, just for the record (and to avoid confusing later readers):
    the next_post tag and the next_posts_link are two different things!
    The first should be used on single post view (usually for single.php) and the other one is to be used on index, archive - wherever more posts are listed.

  8. Ryan Fitzer
    Member
    Posted 8 years ago #

    Thanks, good to know. I'll read up on the former.

Topic Closed

This topic has been closed to new replies.

About this Topic