WordPress.org

Ready to get started?Download WordPress

Forums

How do I make "next post" not a link, title a link? (8 posts)

  1. Joy Livingwell
    Member
    Posted 4 years ago #

    How do I use the Previous Post/Next Post functionality so that

    1. my "Previous post: " and "Next post: " text is NOT part of the link, so I can style it,
    2. the post titles ARE links,
    3. and everything works automatically as usual with WordPress?

    I love the implementation on Steve Bauer's blog HowToMasterNLP.com, and would like to do something similar. Scroll down to the bottom of this page to see an example.

  2. vtxyzzy
    Member
    Posted 4 years ago #

    What theme are you using? Can you post a link to your site?

  3. Joy Livingwell
    Member
    Posted 4 years ago #

    My blog is Living Well NLP.

    I use a modified WP-Andreas01 theme.

    Here's the code I currently use on the Single Post template (single.php):

    <div class="navigation">
    <p><span class="prevlink"><?php previous_post(); ?></span></p>
    <p><span class="prevlink"><?php next_post(); ?></p>
    </div>
  4. Joy Livingwell
    Member
    Posted 4 years ago #

    ...and yes, I deliberately use the "prevlink" style on both Previous and Next links. ;-)

  5. vtxyzzy
    Member
    Posted 4 years ago #

    I'm guessing a little here, but is this what you want?

    <div class="navigation">
    <p><span class="prevlink">My Previous Post: <?php previous_post_link('%link'); ?></span></p>
    <p><span class="prevlink">My Next Post: <?php next_post_link('%link'); ?></span></p>
    </div>

    See this reference.

  6. alchymyth
    Forum Moderator
    Posted 4 years ago #

    http://codex.wordpress.org/Template_Tags/previous_post_link:
    use <?php previous_post_link('%link'); ?> to get just the link;
    write your fixed text infront of it.

    workaround for the the first and last post:
    (thanks to: http://digwp.com/2009/12/optimizing-wordpress-post-navigation/ ) - i leave it to you to get your formatting around it ;-)

    <?php if(get_adjacent_post(false, '', false)) { echo 'Next article: '; next_post_link('%link'); } ; ?>
    <br />
    <?php if(get_adjacent_post(false, '', true)) { echo 'Previous article: '; previous_post_link('%link'); } ; ?>

    @vtxyzzy:
    i had my editing window open, so i missed your reply.
    searching and reading the codex always helps ;-)

  7. vtxyzzy
    Member
    Posted 4 years ago #

    @alchymyth - like your answer with the first/last post workaround.

  8. alchymyth
    Forum Moderator
    Posted 4 years ago #

    not mine - credits go to Jeff Starr ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic