Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #19112

    From a single post, how do I change the links at the bottom of the post to display links to the previous & next post in the same category?

    It currently displays links to the previous and next post of any category.

    Thanks in advance,

    – LL

    #102269

    Hi,

    Open single.php and find this code

    <div class='post_nav'>
    <div class='previous_post_link_align'>
    <?php previous_post_link('<span class="previous_post_link">&larr; %link </span>'); ?>
    </div>
    <div class='next_post_link_align'>
    <?php next_post_link('<span class="next_post_link">%link &rarr;</span>'); ?>
    </div>
    </div> <!-- end navigation -->

    Replace it with this code

    <div class='post_nav'>
    <div class='previous_post_link_align'>
    <?php previous_post_link('<span class="previous_post_link">&larr; %link </span>', '%title', TRUE); ?>
    </div>
    <div class='next_post_link_align'>
    <?php next_post_link('<span class="next_post_link">%link &rarr;</span>', '%title', TRUE); ?>
    </div>
    </div> <!-- end navigation -->

    Regards,

    Ismael

    #102270

    Hi. Im having the same issue with my portfolio next & previous buttons. I used the code above but its still showing up categories from other.

    #102271

    Hi Zedduo,

    As long as it has the true in the function it should only be able to pull from the same category. See the codex entry for previous_post_link here: http://codex.wordpress.org/Function_Reference/previous_post_link#Text_As_Link.2C_Without_Post_Title.2C_Within_Same_Category

    Try refreshing your page a few times to make sure you aren’t looking at a cached version where your code change hasn’t been applied.

    Regards,

    Devin

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Previous & next post in the same category’ is closed to new replies.