danielanieliel
Member
Posted 1 year ago #
Hello guys,
I am confronted with a problem. Let's say I have a custom post type and want to show 4 posts at the end of the article, that come before and after that post. An advanced next_post_link() and previous_post_link() so to say.
Eg. I have 10 articles:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
I am now at article 7 and want to show a list of the following:
4.
5.
8.
9.
I am clueless and would kindly appreciate help.
Jeremy Boggs
Member
Posted 1 year ago #
I was a bit curious how to do this as well, so I wrote a rough plugin to accomplish this. It's available right now in my GitHub repository.
it makes two functions available: multiple_next_post_links() and multiple_previous_post_links() that will display any number of previous or next links. Passing a number as an argument to either function will return that many posts if available. You should use these instead of next_post_link or previous_post_link, at least as the plugin is currently written.
I'd be curious to see if this works for you. I may improve it and release if it seems useful.