Title: Query two previous and next posts
Last modified: August 19, 2016

---

# Query two previous and next posts

 *  [danielanieliel](https://wordpress.org/support/users/danielanieliel/)
 * (@danielanieliel)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-two-previous-and-next-posts/)
 * 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.

Viewing 1 replies (of 1 total)

 *  [Jeremy Boggs](https://wordpress.org/support/users/jeremyboggs/)
 * (@jeremyboggs)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-two-previous-and-next-posts/#post-2000851)
 * 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](https://github.com/clioweb/multiple-adjacent-post-links).
 * 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.

Viewing 1 replies (of 1 total)

The topic ‘Query two previous and next posts’ is closed to new replies.

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * 1 reply
 * 2 participants
 * Last reply from: [Jeremy Boggs](https://wordpress.org/support/users/jeremyboggs/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/query-two-previous-and-next-posts/#post-2000851)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
