How to get a gallery as an array
-
I’m working on a website where I use a custom post type with lots of custom fields, multiple galleries and a featured image. One gallery uses a jquery plug-in, the other one uses the gallery shortcode.
At first, when I only had the jquery gallery, I simply grabbed all images attached to the given post, excluded the featured image and chucked them in a mark-up that the plug-in uses with this code:
$a_args = array( 'post_type' => 'attachment', 'post_parent' => $post->ID, 'posts_per_page' => -1, 'post_mime_type' => 'image', 'exclude' => get_post_thumbnail_id( $post->ID ), ); $a_images = get_children( $a_args );
However, now that I’ve added another gallery (this one is only output with the gallery shortcode) my solution doesn’t work as desired, because it takes all the images – even the ones from the other gallery.
So ideally I would like to get an array of images that would be output by the gallery shortcode as simply as possible.
How do I do this ?
- The topic ‘How to get a gallery as an array’ is closed to new replies.