certainlyakey
7/28/2014 - 8:24 PM

Wordpress - get attached to post files and show them in a list

Wordpress - get attached to post files and show them in a list

<?php 
	$args = array(
		'numberposts' => -1, // Using -1 loads all posts  
		'post_mime_type' => 'application', // Make sure it doesn't pull other resources, like videos  
		'post_parent' => $post->ID, // Important part - ensures the associated images are loaded 
		'post_status' => null, 
		'post_type' => 'attachment'
	);
	
	$atts = get_children( $args );
	if ($atts) { ?>  
	<ul class="linklist">
		<?php foreach ( (array) $atts as $att_id => $att ) {
			echo "<li>".wp_get_attachment_link( $att_id )." (".strtolower(size_format(filesize(get_attached_file( $att_id )))).")</li>";
		} ?>
	</ul>
	<?php } ?>