Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created a category and call it "Blog". Then I created some posts and assign "Blog" as category for the posts. So I'm trying to go to previous/next into the same category and doesn't work. Here is my code:

<nav id="nav-single">
    <span class="nav-previous"><?php previous_post_link('%link', __('<span class="meta-nav">&larr;</span> Previous'), TRUE); ?></span>
    <span class="nav-next"><?php next_post_link('%link', __('Next <span class="meta-nav">&rarr;</span>'), TRUE); ?></span>
</nav><!-- #nav-single -->

None of the links is being displayed even if I have more than one post created. If I remove the TRUE value then it goes to other categories. What am I doing wrong?

share|improve this question
add comment

2 Answers

This is the default in WordPress Twenty Eleven Theme

<nav id="nav-single">
        <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
        <span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">&larr;</span> Previous', 'twentyeleven' ) ); ?></span>
        <span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></span>
</nav><!-- #nav-single -->

I copy pasted your code to replace the above default code.

<nav id="nav-single">
    <span class="nav-previous"><?php previous_post_link('%link', __('<span class="meta-nav">&larr;</span> Previous'), TRUE); ?></span>
    <span class="nav-next"><?php next_post_link('%link', __('Next <span class="meta-nav">&rarr;</span>'), TRUE); ?></span>
</nav><!-- #nav-single -->

Your code is working perfectly on my system. Your code doesn't have any problem. You can refer to Codex for changing your code further.

http://codex.wordpress.org/Function_Reference/previous_post_link

share|improve this answer
add comment

This worked for me:

<div id="nav-single">           
<div class="nav-previous"><?php previous_post_link('&#8249; %link', '%title', 'Next post in category', TRUE); ?> </div>
<div class="nav-next"><?php next_post_link('%link &#8250;', '%title', 'Next post in category', TRUE); ?> </div>         
</div><!-- end of #nav-single -->'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.