WordPress.org

Ready to get started?Download WordPress

Forums

next_post_link/previous_post_link only for parent category (1 post)

  1. Trangsene
    Member
    Posted 3 years ago #

    Hello,
    I have my posts organized in categories and subcategories.
    In my theme, I have links to previous and next posts on my single page, but it shows these links even if previous and next posts are from a different parent category.

    How is it possible to limit this function only to my parent category, and all its child categories?

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

    in_same_cat
    (boolean) Indicates whether previous post must be within the same category as the current post. If set to TRUE, only posts from the current category will be displayed. Options are:

    * TRUE
    * FALSE (Default)

    Its almost what I need, but I don't see how to use it for a parent category.

    If anyone has an idea... Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic