Support » Themes and Templates » How do I get a list of all images attached to a single post?
7 years, 8 months ago
If I have a post and I go to add images I can add images to its Gallery without inserting them into the actual post.
What I need to do is build a CSV list of the paths to all of the images to pass to Flash.
Anyone have any ideas?
7 years, 7 months ago
You will want to look at get_children(). A good example of usage is in wp-admin/includes/media.php at line 1058 (in 2.8)
$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
That code comes from the function get_media_items() that’s worth reviewing.
I used this code once with a slightly different purpose. But it should be no problem to change it so it will match your needs…