Skip to content

Instantly share code, notes, and snippets.

@BronsonQuick
BronsonQuick / loop_through_post_attachments.php
Created March 4, 2012 06:56
A WordPress loop to display post/page attachments
<?php /*
* This is just a simple loop to display 7 attachments attached to a post or page in WordPress
* You can change 'medium' and 'thumbnail' to add sizes you have definied in your theme by the add_image_size function
* in WordPress
*/
?>
<div id="thumbs" class="pic_list">
<ul class="thumbs">
<?php /* Time to create a new loop that pulls out the first 7 image attachments for this post */
$args = array( 'post_type' => 'attachment', 'numberposts' => 7, 'post_status' => null, 'post_parent' => $post->ID );