Wordpress 如何获得附件的日期?
我不知道如何获得附件的日期。本人获取附件如下:Wordpress 如何获得附件的日期?,wordpress,date,attachment,Wordpress,Date,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 } 有什么想法
$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
}
有什么想法吗?谢谢你的关注 附件是一种帖子类型,是一天结束时的自定义帖子类型。因此,它们与其他职位类型共享完全相同的表和特征 这只是一个问题:
foreach ( $attachments as $attachment ) {
echo $attachment->post_title . ' - ' . $attachment->post_date;
}
如果您需要特定的附件元数据,它们有专门的功能,就像@brbcoding in comments所建议的那样。我没有运行WP的副本,但您尝试过吗?我甚至不知道它返回了什么,但在我看来,它可能包含一个上载日期。如果您
打印($attachment)
它是否没有一个包含发布日期的字段?如果是这样,您可以echo
$attachment->pub_date`或任何变量名称。