Skip to content

Instantly share code, notes, and snippets.

@codescribblr
Created February 13, 2014 21:42
Show Gist options
  • Select an option

  • Save codescribblr/8984470 to your computer and use it in GitHub Desktop.

Select an option

Save codescribblr/8984470 to your computer and use it in GitHub Desktop.
Using Advanced Custom Fields\' Relationship Field to show attachments of a related post
foreach(get_field('relationship') as $related) :
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $related->ID,
);
$attachments = get_posts( $args );
foreach ( $attachments as $attachment ) :
$headshot = wp_get_attachment_image_src($attachment->ID, "medium");
echo $headshot[0];echo "<br />";
endforeach;
endforeach;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment