WordPress.org

Ready to get started?Download WordPress

Forums

Next/Previous post in same category? (18 posts)

  1. Atrus
    Member
    Posted 9 years ago #

    Is there a way to fix the 'in_same_cat' option in previous_post() and next_post()? It's been broken for as long as I can remember.

    I've been using a plugin that does the same work but it only works by ID and not by date, which is a bit of a problem since most of my posts aren't in chronological order.

  2. Kafkaesqui

    Posted 9 years ago #

  3. Atrus
    Member
    Posted 9 years ago #

    I tried the Meyerweb plugin but the same category option seems to be broken all the same.
    The one by Scriptygoddess is what I'm using right now, but it only works by post ID and not by date. I'm no good at SQL queries so I wouldn't know how to fix that.

  4. Lorelle
    Member
    Posted 9 years ago #

    Has the issue of getting next/previous posts within the category of the post been solved? The "within category" feature doesn't seem to work...yet...on the template tags.

    I gave Meyer's next/previous tags a whirl and they work ~~okay~~. I had to fix the code to force it to work.

    <?php mw_previous_post('%', '', 'The previous article is ', '.', 'yes', 'yes') ?>
    <?php mw_next_post('%', '', ' The next article is ', '.', 'yes', 'yes') ?>

    From Meyer's next/previous plugin returns:

    "The previous article is Previous Article Title. The next article is Next Article Title. "

    The problem is that I can't get it to do posts from within the same category. It still follows chronological from any category. Not what I want.

    From Scriptgodess next/previous posts in same category I was able to create a similar effect, but the plugin grabs every category that post is in and gives you the next and previous from each category. So if I have one post that is in three categories, along with three other "similar" articles, I get three lists of previous articles, all the same title, and three lists of next articles, all the same title. Not good.

    So the Scriptgoddess code does what I want, but I would have to keep every post in ONE category. Since I have a lot of subcategories, this makes it complicated because if I have a Parent Category 1, with the post in Sub-Category 3, I still get a listing for the next and previous in Parent Category 1 and two each for Sub-Category 3. For links to the same two articles I do not need.

    Has anyone found anything better for keeping the next/previous postings WITHIN the same category?

  5. Lorelle
    Member
    Posted 9 years ago #

    bump

  6. Jaqueline
    Member
    Posted 9 years ago #

    That´s it... I thought I did something wrong, but looks like Meyer's plugin behavies as the default WordPress functions next_post and previous_post, at least at Wp 1.5.
    Thank God it´s not just ME! LOL

  7. Lorelle
    Member
    Posted 9 years ago #

    It's not you. But I sure wish it was US getting it right! I'm desperate to keep my NEXT and PREVIOUS in the same category. Any luck in finding any working code solution?

  8. Lorelle
    Member
    Posted 9 years ago #

    bump

  9. Jaqueline
    Member
    Posted 9 years ago #

    Lorelle... nothing seems to work. I tried Scriptgoddess too and had the same problem as you did, because a lot of my posts are in two or maybe three different categories.

    I´m thinking about merging some categories and using posts in just one. Can´t think on anything else, nothing is working!!

  10. Lorelle
    Member
    Posted 9 years ago #

    There just HAS to be a fix to this. It's making me nuts. It's about the last thing that I want to fix before going public with my new WordPress site that I've been working on for MONTHS.

    Anyone?

  11. Lorelle
    Member
    Posted 9 years ago #

    bump

  12. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    This has been broken ever since multiple categories per post functionality was introduced. Multiple categories complicates matters. Are two posts considered to be "in the same category" if they have any category in common. If so, when navigating from post A to post B to post C, posts A and C may have no category in common. A and C can share a category with B but not with each other.

  13. Jaqueline
    Member
    Posted 9 years ago #

    Ryan, that's not true. I use it, and it show all categories, even the posts that are in another category, alone.

    I wouldn't like my "personal blog" to be among all the other posts, and it has it´s own category, but using PREV, NEXT, even with Meyer's plugin, shows everything!
    I don´t think there is a solution for this!

  14. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    I'm talking about what the fixed behavior should or should not be, not what the current behavior is. The current behavior is obviously broken.

  15. Jaqueline
    Member
    Posted 9 years ago #

    ok! now I got it! lol
    you can see english is not my language at all! ;)

  16. admiralnovia
    Member
    Posted 8 years ago #

    So, 8 months later, and there is no fix or work around for this, right? It would be nice if someone would re-enable the $excluded_categories parameters of:
    * get_previous_post()
    * get_next_post()
    * previous_post_link()
    * next_post_link()
    so that when one wants something in the SAME category that happens to be in MULTIPLE categeories, that they can EXCLUDE the categeories that they don't want.

  17. ABetterUsername
    Member
    Posted 8 years ago #

    Was this ever resolved?

  18. tsguitar
    Member
    Posted 8 years ago #

    It just so happens there is another thread on this currently. I looked around and figured a few things out. Here's what I tried on my blog and it worked (WP 2.0.4):
    <?php previous_post_link($format='&laquo %link', $link='%title', $in_same_cat = true); ?>

    The same thing should work for next_post_link. The Codex doesn't have this covered, but Owen does:
    http://www.redalt.com/fn/1678

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.