I’m currently building a website where a custom post type needs to show a gallery of images per post. Below image is what I was after:
To do this I would upload the images when creating the post so that the images would be attached to the post, or in other words the attachments where child posts of this post I was creating. I found some code that grabs the attachments but the code didn’t retrieve the results by the order I have specified in the upload manager when uploading the image. To get the images in order I had to write a little more code to what I had found.
Anyway here is the finished code http://pastebin.com/wEvW0WHZ. It’s tailored to my needs but here you can see how the image attachments are being pulled and then how im sorting the results to go in the correct order. Hope it is some use to someone.