0
我有以下代码:获取附着物只为这个职位
<?php
include('includes/index.php');
get_header();
?>
<section>
<div class="text">
<?php
while (have_posts()):
the_post();
if (get_the_title() == 'Archive') query_posts('posts_per_page=1&cat=1');
$category = get_the_category();
if ($category[0]->name) echo '<h1>'.$category[0]->name.'</h1>';
$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image'));
foreach ($attachments as $attachment_id => $attachment):
$image = wp_get_attachment_url($attachment_id, 'medium');
echo $image."<br />";
endforeach;
the_content();
endwhile;
?>
<?php edit_post_link('Click here in order to edit this page'); ?>
</div><!--END /.text-->
</section>
</div><!-- end clearfix-->
<?php get_footer(); ?>
此代码是在page.php
其中默认我列出post.I想要得到的附着物仅针对后query_posts('posts_per_page=1&cat=1');
现在它也得到该页面的附件。,我该如何做到这一点?
通过告诉query_posts(或更好的自定义查询对象),你会喜欢的一个特定的职位。请参阅http://codex.wordpress.org/Function_Reference/WP_Query – hakre