Change Sort Order of Image Attachment Pages
-
Hi, I’ll try to break this down as clearly as possible:
I have several galleries.
The images in each gallery are sorted (alphabetically by last name) according to the image slug.
When you click an image in the gallery, it takes you to the attachment page for that image.
The attachment pages also have navigation so you can cycle through them using previous_image_link / next_image_linkMy problem is that the attachment page navigation cycles through the pages in order of date uploaded, rather than by slug like the galleries.
So, how can I sort my image attachment pages by slug?
I’m terrible at php, but I’ve researched it and it looks like I’ll need to create a new WP_Query for attachments. Something like this?
$attachment_navigation = new WP_Query( array( 'post_type' => 'attachment', 'post_parent' => null, 'post_mime_type' => 'image', 'post_status' => 'inherit', 'orderby' => 'slug', 'order' => 'ASC', ) );
From what I’ve read though, orderby slug doesn’t work — what should I use instead?
And then — what else? Do I have to write another function to put it into effect? PHP newb here…
Thanks for your help!
- The topic ‘Change Sort Order of Image Attachment Pages’ is closed to new replies.