Return to Snippet

Revision: 52560
at October 26, 2011 14:42 by bitsculptor


Updated Code
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;

Revision: 52559
at October 26, 2011 14:33 by bitsculptor


Initial Code
foreach(get_field('relationship') as $related) : 
	// var_dump($related->ID);
	$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;

Initial URL

                                

Initial Description

                                

Initial Title
Using Advanced Custom Fields\' Relationship Field to show attachments of a related post

Initial Tags
wordpress

Initial Language
PHP