显示我创建theme.I已动态添加的所有类别进入前menu.Now我希望所有的类别下的职位的WordPress的,当我在任何菜单上单击item.But代码获取所有类别的所有帖子。这里是我的代码。特定类别的所有WordPress的帖子将在page.php文件
<?php
global $wp_query;
$id = $wp_query->post->ID;
$the_query = new WP_Query($id);
$count = 0;
// The Loop
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();?>
<div class="page-header"><h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3></div>
<?php
$count++;
}
} else {?>
no posts found
<?php }
/* Restore original Post Data */
wp_reset_postdata();
?>
我该如何解决这个问题。
如果你回声出的$ id是什么打印出来? – Howli
然后被印刷类别ID ok.I已经测试它。但是,当我想要打印该类别下的所有的职位,则所有类别的所有的职位prints.how我可以解决这个问题。 –