Start Using WordPress Attachments Now
No comments |Check it out: How often have you wanted to add an attachment for a specific post in WordPress? This little snippet of PHP will let you do just that. It loads attachments into an array ($args), and then lists them (foreach...) with their respective titles (the_title).
$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);
}
}




subscribe to comments RSS
There are no comments for this post