A gallery is at heart just the set of attached posts, so...
$post_id = 1; // set to your desired parent post
$attachments = new WP_Query(
array(
'post_parent' => $post_id, // post to which the gallery is attached
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
// 'order' => $order,
// 'orderby' => $orderby
)
);
// var_dump($attachments); // debug
foreach ($attachments->posts as $p) {
var_dump($p);
var_dump(wp_get_attachment_image_src($p->ID));
var_dump(get_post_custom($p->ID));
}
You should be able to find all you need, and a lot more, in that dumped data. In fact, I think that all you need is in the last two of those dumps so you can probably simplify to this:
$post_id = 1; // set to your desired parent post
$attachments = new WP_Query(
array(
'fields' => 'ids',
'post_parent' => $post_id, // post to which the gallery is attached
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
// 'order' => $order,
// 'orderby' => $orderby
)
);
// var_dump($attachments);
foreach ($attachments->posts as $ids) {
var_dump(wp_get_attachment_image_src($ids));
var_dump(get_post_custom($ids));
}
<figure><img src='image source' title='image title' /><figcaption>image caption, image alt tag</figcaption></figure>
.