How to retrieve attachments from child pages of a specific Page?

You’re going about this the right way …

  1. Your query is like a loop … so to limit total images you’d need to add them all to an array first, and then how would you determine how to limit the total
    eg what if one page had 50 images and the next page had 1

  2. Along with your first point … your current code is a Loop that runs through each child page. So you would need to get all your images into an array first and you can randomise them.

Suggestion – try this WordPress Codex wp_get_attachment_image to list the images on your pages

and compare it with your codex / code sample http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments

Damien