Title: Dynamically select recent posts using sql query
Last modified: August 19, 2016

---

# Dynamically select recent posts using sql query

 *  [ktharri](https://wordpress.org/support/users/ktharri/)
 * (@ktharri)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/dynamically-select-recent-posts-using-sql-query/)
 * Hi,
 * scenario: I am building a photoblog for a friend based of a free photoblog template
   but changed considerably, I have thumbnails of posts lining up in rows as a kind
   of thumbnail gallery, the list of posts is retrieved by an sql query within a
   function, howeever looking at the query i think it is always going to show the
   most recent posts, ive set it to display 35 posts, even if someone is looking
   at an older post.
 * what i am looking for is a way to make the thumbnail list disply the posts that
   were made nearest to the currently viewed post. so if someone is looking at a
   recent post, the see all the most recent posts, but if someone had gone into 
   the archives and is viewing a post from july last year, the thumbnail list actually
   shows all the other posts from the period.
 * I thought about filtering the query by month, but I do not want it to be neccesary
   to update a certain amount of photos every month for the full thumbnail gallery
   to display, for that is software dictating to a user which is poor.
 * does anyone have an idea how to acheive this? I am not married to the sql function
   method for displaying this thumbnail list, so if someone knows a better way I
   am definately open and grateful

Viewing 1 replies (of 1 total)

 *  [shane-g](https://wordpress.org/support/users/shane-g/)
 * (@shane-g)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/dynamically-select-recent-posts-using-sql-query/#post-1222432)
 * Hi,
 * Check with these plugins:
 * [http://wordpress.org/extend/plugins/random-featured-post-plugin/](http://wordpress.org/extend/plugins/random-featured-post-plugin/)
   
   [http://wordpress.org/extend/plugins/random-posts-plugin/](http://wordpress.org/extend/plugins/random-posts-plugin/)
 * Thanks,
 * Shane G.

Viewing 1 replies (of 1 total)

The topic ‘Dynamically select recent posts using sql query’ is closed to new replies.

## Tags

 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)
 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [shane-g](https://wordpress.org/support/users/shane-g/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/dynamically-select-recent-posts-using-sql-query/#post-1222432)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
