next and previous post in same category (4 posts)

  1. yolise
    Posted 7 years ago #

    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?

  2. yolise
    Posted 7 years ago #

    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.

  3. KAy1313
    Posted 7 years ago #

    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.

  4. tomboersma
    Posted 7 years ago #

    Thanks, that works!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.