Forums

Restrict "previous_post_link" and "next_post_link" to same child category (5 posts)

  1. tshirtfiend
    Member
    Posted 6 months ago #

    I would like to be able to navigate between posts in the same child category. I know with previous_post_link and next_post_link you can restrict navigation to the same parent category, but I can't seem to find a way to restrict it to just the child category with the parameters available. Am I missing something?

  2. timDesain
    Member
    Posted 6 months ago #

    have you read this page?

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

    Text As Link, Without Post Title, Within Same Category
    Displays custom text as link to the next post within the same category as the current post. Post title is not included here. "Next post in category" is the custom text, which can be changed to fit your requirements.

    <?php next_post_link('%link', 'Next post in category', TRUE); ?>

  3. tshirtfiend
    Member
    Posted 6 months ago #

    Yes, I did read that page. I have the parameters set up as in the snippet you posted. The issue is that the posts in question all share a parent category, but have different child categories.

    If I set the "in category" parameter to "TRUE", it goes through the posts in the same parent category, but doesn't restrict it to the child.

    Any thoughts?

  4. MatthewEbel
    Member
    Posted 1 month ago #

    Yeah, I'm having this problem too... I just want to be able to navigate within a specific category, not its parent.

  5. tshirtfiend
    Member
    Posted 1 month ago #

    Let me know if you figure it out. I still haven't found a solution…and it's a bit of a sore spot on my site.

Reply

You must log in to post.

About this Topic