• I’ve spent time browsing the plugins directory and forum for a solution but can’t seem to find one, so hence this thread.

    I want to display the next 5 posts and previous 5 posts in the same category on the sidebar on single post pages.

    So instead of having the 10 latest posts in the same category, I will display the 10 adjacent posts.

    I’m not a programmer but it seems like something simple, can you help me?

    If this question is unclear, please ask for clarification.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter futilebrands

    (@futilebrands)

    Any ideas on this?

    but it seems like something simple
    No, it’s not.
    I don’t know of any plugin/widget that would do it… probably, it would require to many queries (which slows down the site) to be worth to think about it.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    This is actually very tricky for a number of reasons.

    a) When you say “same category”, that doesn’t make sense because posts can be in more than one category. This is a common mistake caused by people thinking that posts go “into” categories somehow. Categories are not like folders full of posts, categories are like labels attached to posts.

    b) Getting the “next 5” or “previous 5” is shockingly difficult because WordPress is designed to retrieve some set of posts starting with some given post, based on chronological order. So you need to advance 5 posts into the “future” (posts which may not exist) and then retrieve 10 posts back. Or less, for the case where you’re looking at the most recent 5 posts. You can do some trickiness with the orderby parameter there, if you could start at the “current post” on the single post page.

    c) But you kinda can’t, it’s not designed to start at a specific post, it’s designed to start at a specific post given it’s position in the series of the total posts. And getting that value is damn tricky.

    d) Getting posts isn’t made to revolve around a center point, but from a beginning. This makes it even trickier.

    And so on.. In the end, while it could be done if you made some assumptions (posts only in one category, etc), it’s likely not worth the effort.

    Thread Starter futilebrands

    (@futilebrands)

    well thanks otto and moshu, at least I can end my search now.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display Next 5 posts?’ is closed to new replies.