treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress - single-post template and the loop

  • Hi, I also posted this to the Wordpress.org forums, but no one seems to have been able to help yet, so I'm trying my luck here as well.

    I have a problem that I can't seem to solve on my own:
    I'm doing this portfolio for a photographer friend, and we're uploading each picture as a new blog entry, attaching it using the "featured image"-feature.
    That's not the problem, works fine.

    The thing is I want to be able to cycle through all the pictures, jcarousel-wise, in each category. Right now when viewing a single picture, I load it through the single-post-template-file, and then using next_post_link() and previous_post_link(), you can go to the next or previous picture. That also works fine.

    But I figure, if I want to be able to loop through the pictures with jcarousel, I need to write some changes to the loop in the single-post-template.

    I need to load:
    1. the current post (like now; post no. 5 for instance in a category)
    2. all the next posts in the category (no. 5 to 10 for instance)
    3. all the posts before the current post (no. 1 to 4 for instance)

    I don't suspect this to be too complicated, I just can't seem to wrap my head around it on my own.
    Thank you very much to everyone with ideas to throw in.

    //A.
  • I think it would be better to create a custom template page. That way you can write your own custom loop and get your jcarousel style going.
  • Yep, and that's exactly the question: how do I write the loop so that it loads the posts the way I've specified. I write custom template pages all the time, but this particular problem seems to stick.