0
我想制作一个自定义的Wordpress模板/页面,其中我列出了几个子类别中帖子所附的PDF。 我发现了几个片段,但我无法让他们工作。 我的PHP技能有限。列出附加的PDF和帖子中的类别。 WordPress的
这给我所有附加的PDF,但我想要4个不同的列表,每个类别一个。
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_mime_type' => 'application/pdf',
'post_parent' => null,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
?>
<ul class="">
<li class=""><h2>Sub-Category-Name</h2>
<ul>
<li>
<?php
the_attachment_link($post->ID, false);
echo '</li>';
}
}
?>
请阅读[这里](http://wordpress.org/support/topic/pulling-attachments-from-specific-post-categories)。 – montrealist 2013-05-06 15:10:51