You will need to modify the Loop to use a function such as get_children(), and then output the results.
This function will return an array of attachment IDs, that you can use to output the attachments, or links to the attachments, or whatever you’re wanting to do.
Thread Starter
Gesp
(@gesp)
Can you show me how I can do it please?
Not really, without knowing exactly what you want to do.
Did you read the linked Codex page? It explains how to use the function in general.
Thread Starter
Gesp
(@gesp)
I wanted to pull every attachment from a page and hang it on the masonry grid, but I need that code to do it. I can do it with posts because the usual loop pulls the posts already.
I wanted a loop that only pulled the attachments.
Then you want to use something like get_posts() to create an ad-hoc Loop. e.g.
$postattachments = get_posts( array(
'numberposts' = -1,
'post_type' = 'attachment',
'post_parent' = $post->ID
) );
This will add an array containing all of the attachments for the current post.
Then you need to output them:
foreach ( $postattachments as $attachment ) {
// Add your HTML markup here
// I don't know what it is, so you'll have to figure this part out
// However, this will output the 'thumbnail' size image:
echo wp_get_attachment_image( $attachment->ID, 'thumbnail' );
}