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; ?>
我該如何修改循環以僅過濾「類型」分類標準的當前分類標準?