Last active
February 2, 2016 11:43
-
-
Save RafaelFunchal/5040724 to your computer and use it in GitHub Desktop.
Show all 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
<?php | |
$attachment_args = array( | |
'post_type' => 'attachment', | |
'numberposts' => -1, | |
'post_status' => 'any', | |
'post_parent' => get_the_ID() | |
); | |
$attachments = get_posts( $attachment_args ); | |
if ( $attachments ) { | |
$attachment_return = '<ul class="attachments">'; | |
foreach ( $attachments as $attachment ) { | |
$attachment_src = wp_get_attachment_image_src( $attachment->ID, 'full' ); | |
$attachment_return .= '<li>'; | |
$attachment_return .= '<a rel="INSERT_YOUR_CLASS_HERE" href="'. $attachment_src[0] .'" title="'. apply_filters( 'the_title', $attachment->post_title ) .'">'; | |
$attachment_return .= wp_get_attachment_image( $attachment->ID, 'thumbnail' ); | |
$attachment_return .= '</a>'; | |
$attachment_return .= '</li>'; | |
} | |
$attachment_return .= '</ul>'; | |
echo $attachment_return; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment