How to show WordPress post attachments

November 6 2009, 1:04am

To achieve this recipe, just paste the following code anywhere in your post.php file and attachments will be displayed.

$args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { echo apply_filters('the_title', $attachment->post_title); the_attachment_link($attachment->ID, false); } }

Credit : Snipplr. Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to show WordPress post attachments