0
我有一个自定义后类型的“项目”分类学名为“类型”的子导航:自定义文章类型分类页面仍然显示的所有帖子
<?php $args = array('post_type' => 'projects');
$the_query = new WP_Query($args); ?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php $terms = get_terms('type');
$currentterm = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
echo '<ul class="sub-nav-menu">';
foreach ($terms as $term) {
$class = $currentterm->slug == $term->slug ? 'live' : '' ;
echo '<li><a href="'.get_term_link($term).'" class="'. $class .'">'.$term->name.'</a></li>';
}
echo '</ul>'; ?>
<?php endwhile; ?>
<?php endif; ?>
当分类点击它把你的分类页面分类-type.php。
尽管此页面仍显示所有自定义帖子类型,而不仅仅是当前分类页面的类型。
<?php $args = array('post_type' => 'projects');
$the_query = new WP_Query($args); ?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?php $terms = get_terms('type'); ?>
<a href="<?php the_permalink() ?>">
<h3><?php the_title(); ?></h3>
</a>
<?php wp_reset_postdata(); ?>
<?php endwhile; ?>
<?php endif; ?>
我该如何修改循环以仅过滤“类型”分类标准的当前分类标准?