I created a snippet to get all attachment from a post, included attachments from comments.
<?php
$post_attachments = get_posts( array (
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $post->ID
));
?>
<ul class="attach-list-post">
<?php
foreach ( $post_attachments as $post_attachment ) {
$name = $post_attachment->post_title;
$date = $post_attachment->post_date;
echo '<li>' . wp_get_attachment_link( $post_attachment->ID, '', false, false ) . $name . $date . '</li>';
}
?>
</ul>
It returns also the date of the attachment. Now, I need to return also the username of the user who attached the file, that can be the user who commented the post. I've tried using:
$author = $post_attachment->post_author;
but it doesn't return any kind of value.
Any suggestion on this?