3

添付ファイルの日付を取得する方法がわかりません。次のように添付ファイルを取得します。

$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
}

何か案は?ご覧いただきありがとうございます。

4

1 に答える 1

3

添付ファイルは投稿の一種であり、最終的にはカスタム投稿タイプです。そのため、他の投稿タイプとまったく同じテーブルと特性を共有しています。

それはただの問題です:

foreach ( $attachments as $attachment ) {
    echo $attachment->post_title . ' - ' . $attachment->post_date;
}

特定の添付ファイルのメタデータが必要な場合はwp_get_attachment_metadata、コメントの @brbcoding で提案されているように、特殊な機能があります。

于 2013-07-12T00:16:23.527 に答える