Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Attachments from a post

$args = array(
‘post_parent’ => $post->ID,
‘post_type’ => ‘attachment’,
‘post_status’ => ‘any’,
‘fields’ => ‘ids’
);
$att = new WP_Query( $args );

// WP_Query arguments
$args = array (
	'post_parent'            => '$post->ID',
	'post_type'              => 'attachment',
	'post_status'            => 'any',
);

// The Query
$att = new WP_Query( $args );