• Resolved tdako

    (@tdako)


    I’m trying to use the Previous and Next post links in my template and I found that I can do this in the file single.php.

    At the moment, I have the following code:
    <span class=”alignleft”><?php previous_post_link(‘« %link’)?>/span>
    <span class=”alignright”><?php next_post_link(‘%link »’); ?></span>

    This seems to work alright, but I’d like it to show only the posts in the same category. Now, looking at the examples here, I have to add the word TRUE in there somewhere, but wherever I tend to add it, it changes the whole links to a 1.

    How could I make this change?

    Thanks a lot in advance for any help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tdako

    (@tdako)

    This is what I’ve been playing around with:

    This works fine and shows the Previous and Next Posts in the same category, but with the texts “Previous” and “Next”.
    <span class=”alignleft”><?php previous_post_link(‘« %link’, ‘Previous’, TRUE); ?></span>
    <span class=”alignright”><?php next_post_link(‘%link »’, ‘Next’, TRUE); ?></span>

    However, I’d like to have this kind of code, which shows the name of the next and previous posts, but it doesn’t stay in the same category.
    <span class=”alignleft”><?php previous_post_link(‘« %link’); ?></span>
    <span class=”alignright”><?php next_post_link(‘%link »’); ?></span>

    How could I combine the two?

    Thanks a lot

    Thread Starter tdako

    (@tdako)

    Found the solution:

    <span class=”alignleft”><?php previous_post_link(‘« %link’, ‘%title’, TRUE); ?></span>
    <span class=”alignright”><?php next_post_link(‘%link »’, ‘%title’, TRUE); ?></span>

    Change previous and next to %title.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using Previous and Next Post Link’ is closed to new replies.