Get one attachment from next and previous WordPress posts
June 18, 2011 2:25 PM   Subscribe

Fun WordPress question! I'm designing a template and on the image attachment page, I want to be able to display (1) the last image attached to the previous post in the category "gallery," and (2) the first image attached to the next post in the category "gallery," if there are any.

...and I am completely stumped. I'm trying to run multiple loops but nothing's doing it for me. Things I think should work fine aren't. How do I get the adjacent post and then call its first or last image? Is there any script available that does this already, or does anybody have a starting place for me?
posted by aiificionado to Computers & Internet (1 answer total)
 
It you asked how to do with with Drupal, I could tell you. I'm not a WordPress person, but since it's been a day and no one answered, based on my quick googling, I'd say you need to use the code mentioned on the Show Attachments For The Current Post page, but instead of using the current post ($post->ID), you're going to want to use the get_adjacent_post function. There may be a more elegant way (or a more WordPress-ish way) but like I said, I'm not a WordPress guy. I'm not familiar with all the WordPress functions and API calls. Given WordPress' popularity, I'm very surprised that no one has chimed in here.
posted by Brian Puccio at 6:30 PM on June 19, 2011


« Older Macbook's ability to use TV disappeared overnight!...   |   Boombox that plays USB sticks Newer »
This thread is closed to new comments.