我不知道如何获取附件的日期。我获取附件如下:
$attachments = get_children(array('post_parent'=>$post->ID, 'post_type'=>'attachment', 'post_mime_type'=>'image'));
foreach ( $attachments as $attachment ) {
//I want to get the date of the attachment
}
有任何想法吗?感谢您的关注!
我不知道如何获取附件的日期。我获取附件如下:
$attachments = get_children(array('post_parent'=>$post->ID, 'post_type'=>'attachment', 'post_mime_type'=>'image'));
foreach ( $attachments as $attachment ) {
//I want to get the date of the attachment
}
有任何想法吗?感谢您的关注!
Attachment is a type of post, a Custom Post Type at the end of the day. As so, they share exactly the same table and characteristics as other post types.
It's just a matter of:
foreach ( $attachments as $attachment ) {
echo $attachment->post_title . ' - ' . $attachment->post_date;
}
If you need specific attachments metadata, they have specialized functions, like wp_get_attachment_metadata as suggested by @brbcoding in comments.