Support » Themes and Templates » next and previous post in same category

  • Could someone help me figure out what the documentation is saying? I’m afraid I’m not really an expert in formatting code. I want the single page navigation to display the name of the next and previous post only in the category within which it exists. I tried:

    <div class="alignleft"><?php previous_post_link('&laquo; %link', TRUE) ?></div>
    <div class="alignright"><?php next_post_link('%link &raquo;', TRUE) ?></div>


    <div class="alignleft"><?php previous_post_link('&laquo; %link', in_same_cat=TRUE) ?></div>
    <div class="alignright"><?php next_post_link('%link &raquo;', in_same_cat=TRUE) ?></div>


    <div class="alignleft"><?php previous_post_link('&laquo; %link', 'in_same_cat=TRUE') ?></div>
    <div class="alignright"><?php next_post_link('%link &raquo;', 'in_same_cat=TRUE') ?></div>

    …none of which work. What’s the proper format, please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Am I right in guessing this is a long-standing bug and there is actually no way to do this?

    I see no replies to similar queries.

    Encountered the same problem until I had an Eureka moment. Here is what worked for me (and what should work for you):

    <?php previous_post_link('%link', '%title', TRUE); ?>
    <?php next_post_link('%link', '%title', TRUE); ?>

    The trick is to make sure that TRUE is the third argument you are listing, I guess that’s how this function works.

    Thanks, that works!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘next and previous post in same category’ is closed to new replies.