0
我已經找到了一個代碼,以顯示所有媒體文件,但我怎麼列出所有的PDF文件只能用自定義字段如何使用自定義字段顯示所有PDF文件
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
the_excerpt();
}
}
?>
感謝,幫助了很多,但如何顯示的唯一的PDF文件具有對自定義字段值..ex: - custom_file =「文件」 –