WordPress.org

Ready to get started?Download WordPress

Forums

Next and Previous Permalinks Everywhere (2 posts)

  1. tysontate
    Member
    Posted 8 years ago #

    I currently have a WP site which shows one post at a time. To go between the posts, I have "previous" and "next" links. Currently, the navigation code looks like so:

    <li id="previousLink"><?php posts_nav_link('','','&laquo; previous') ?><?php previous_post('%','&laquo; previous', 'no'); ?></li>
    <li id="permaLink"><a href="<?php the_permalink(); ?>">perma-link</a></li>
    <li id="nextLink"><?php posts_nav_link('','next &raquo;','') ?><?php next_post('%','next &raquo;', 'no'); ?></li>

    So, when the user goes to the front page and clicks "previous" etc, they get the link supplied by posts_nav_link() (which is a relative link). When they're using the perma-linked page, they get the next_post() and previous_post() links (which are permalinks).

    However, I'd like the next and previous post links to always be permalinks so that no matter which post someone is looking at, the address in the top is always a permalink to that post (except for the front page, of course). How might I achieve this? I've searched high and low here and in the codex and I still haven't quite found out a way to force the "single page" behavior.

  2. tysontate
    Member
    Posted 8 years ago #

    Annnnddd... Bump! I'm hoping someone has an answer to this.

    Is there a way to do this or will I have to write a some custom PHP code to grab the post id of the "first" post that the user is currently viewing and then create a url from there?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.