Created
August 27, 2012 08:42
-
-
Save guillaumevoisin/3486719 to your computer and use it in GitHub Desktop.
WordPress: Get post attachments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// place inside loop | |
$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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment