wordpressは画像添付ファイルに関しては本当に素晴らしい機能を持っていますが、画像ではない添付ファイルを取得する方法についてのドキュメントは見つかりません。wordpress画像がない添付ファイルを取得
function ok99_get_post_file_attachment($mime='application/pdf',$limit=-1) {
global $post;
$attachments = get_children(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment','post_mime_type' => $mime, 'order' => 'ASC', 'orderby' => 'menu_order ID', 'posts_per_page'=>$limit));
if ($attachments) {
echo 'Your Attachments : <br/>';
foreach ($attachments as $att) {
//$attachment = array_shift($attachments); // debug to delete
echo wp_get_attachment_url($att->ID) . '<br/>';
the_attachment_link($attachment->ID, false);}
}
return false;
}
私の質問です:これは画像でない添付ファイルを取得する唯一の方法である
は今のところ、私はこの関数を書きましたか? 別のクエリなしでこれを行う方法はありますか?
私は少し遅れによあなたの質問が投稿されてからおそらく何かがWordPressで変更されているかもしれませんが、とにかく、私の答えは1つの質問の解決策を参照してください:) – Simon