How do I display images in Wordpress gallery shortcode without gallery shortcode style?

admin

Administrator
Staff member
How can I display images in a gallery shortcode in their gallery order without overriding the gallery shortcode sitewide.

I've already got a custom gallery shortcode in my functions.php. However, in a specific category, I want to display the images in a gallery shortcode in a different way. In wordpress 3.4 and lower, I could just grab attachments and they could be ordered, but that doesn't seem to be the case in the newest versions of wordpress. How can I do this? That is, the gallery shortcode has already been rewritten for 90% of its usage in the site, but I have a couple of posts that require radically different handling of the images in a gallery and I need to pull those images from the shortcode directly in php for placement in the code.

Here's what I want:

I have a post with gallery shortcode
Code:
[gallery ids='5,2,3,4,1,6']
in the content. I already know how to display the text of the post without the shortcode. But I want to grab the shortcode and then use the images associated with those ids, in that specific order. My ideal would be to end with an array of image urls from that gallery
Code:
(5url,2url,3url,4url,1url,6url)
that I could then use with
Code:
<img src="<?php echo gallery[$i]; ?>">