WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to fetch the URLs and captions of all images attached to page x?

share|improve this question
Something like this: wordpress.stackexchange.com/a/93961/21376 ? – s_ha_dum Jul 23 '13 at 23:26
up vote 2 down vote accepted
$is = get_children("post_parent=$id&post_type=attachment&post_mime_type=image");
foreach($is as $i) {
  $url = wp_get_attachment_image_src($i->ID, 'full');
  $caption = $i->post_title);

$id is the id of your post. See http://codex.wordpress.org/Function_Reference/get_children

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.