WordPress.org

Ready to get started?Download WordPress

Forums

Postionation? Previous & Next for parent Category or Subcategory (7 posts)

  1. deftru
    Member
    Posted 3 years ago #

    I am using permalinks: /%category%/%postname%/

    Is there any easy way (or code) to have a categorybased Postination (<Previous and Next> link or title).

    I want that the code asks if the postination(pagination) works within the category or if existing the subcategory.

    To I made myself clear?

    Thanks

  2. Victor Petrescu
    Member
    Posted 3 years ago #

    Here is the syntax for the previous_post_link function:

    <?php previous_post_link($format, $link, $in_same_cat = false, $excluded_categories = ''); ?>

    Here is a working example for what you need:
    <?php previous_post_link('%link', 'Previous in category', TRUE); ?>

    More details here:
    http://codex.wordpress.org/Template_Tags/previous_post_link

  3. Victor Petrescu
    Member
    Posted 3 years ago #

    And of course the next_post_link function:
    http://codex.wordpress.org/Template_Tags/next_post_link

  4. rvlt
    Member
    Posted 3 years ago #

    Same problem here, i used the guidelines on that thread Victor, but the problem is that the next and previous button acts for the top category not the subcategory, im my case i have like:

    furniture
    -chairs
    -sofas

    when i'm in the first sofa post i shouldn't have a previous button, but i have and it goes to last post off chairs subcategory, because is navigating in the main category furniture not the current category of the post.

    Any ideas?

  5. rvlt
    Member
    Posted 3 years ago #

    Hey just found what was my problem, some posts add the main category and the subcategory marked, that's why.

    regards

  6. deftru
    Member
    Posted 3 years ago #

    And how to you get rid of it?

  7. rvlt
    Member
    Posted 3 years ago #

    In my case deftru, i have a ecommerce style website and i had most of the produts with two categories (main and sub) so the buttons will continue to show until the main category reaches the end, so i just need to deselect the main category from every product so that the buttons only read the subcategory.

    regards

Topic Closed

This topic has been closed to new replies.

About this Topic