Get Next 5 Posts from the Current Post
-
This is deceptively simple… I can’t find an answer that works anywhere else in the support forums. On the single post template, I want to generate 5 more recent posts offset from the current post. I’m making an album navigation, so there are 5 CDs (each is a post called from the album category, using custom meta to display a band name and cover image) at the bottom of the single-post template, each one more recent than the next. I want them to be offset from the post you’re currently viewing, so that when you click the next CD, the page refreshes, the single template displays the one you clicked, and you get the next five CDs, and not the most recent 5 cds.
I’ve tried:
1) Playing with get_previous_post() (to attempt to get the next one from the current post). This method ultimately can only get the next or previous post from the current post, but not 4 more.
2) Using offset. I can’t find a way to get 5 posts offset from the current post, though I can obviously get at least 1. I tried multiple custom wp_queries, but there’s no way to establish a starting point in the query() variable.
3) I thought I might be able to do the trick with the Recent Posts plugin, but the skip variable in this plugin always skips from the most recent post in the category, never from the current post.
Any ideas?
- The topic ‘Get Next 5 Posts from the Current Post’ is closed to new replies.