[wp-hackers] Posts Before, Posts After
scribu
scribu at gmail.com
Fri Aug 21 12:05:59 UTC 2009
On Fri, Aug 21, 2009 at 2:46 PM, Thomas Belknap
<dragonfly at dragonflyeye.net>wrote:
> I'm trying to get a "contextual archive" list going, where I can show my
> visitors the next and previous five posts in a list. I would have thought
> this would be easier than it is, but there really isn't any natural way to
> do this with query_posts. According to the examples given in the discussion
> of query_posts in the Codex, to apply a date range, you need to add a
> filter.
I have a plugin that does something like that. It's called Smarter
Navigation <http://scribu.net/wordpress/smarter-navigation> and this is how
it works:
On the index, categories etc.:
- get the current query and change LIMIT
- get post ids with that query and save them in a cookie
On single posts:
- find the current post in the saved post ids
- display previous and next post links.
I'm sure you can tweak template-tags.php so that it shows 5 posts instead of
2.
--
http://scribu.net
More information about the wp-hackers
mailing list