如何显示当前存档中所有帖子的术语或在 wordpress 中查询

How to Display Terms for all posts in Current Archive or Query in wordpress

我有带有 select option.In select 选项的自定义 post 类型我得到了所有分类类别并且在 select 更改时它显示所有 posts 的 post 类型,但是当我转到单个页面时,它只显示当前的 post,而不是该类别的所有内容。我试过这段代码 $term = $wp_query->queried_object; 但它只显示该类别的当前 post 而不是全部。

如何从当前分类类别中获取所有 post。

似乎我得到了 solution.Here 是我的最终代码

$terms = wp_get_post_terms( $post->ID, 'course_type' );
if($terms){
// post has course_type terms attached
$course_terms = array();
foreach ($terms as $term){
 $course_terms[] = $term->slug;
}
$original_query = $wp_query;
$wp_query = null;
$wp_query = new WP_Query( array(
'post_type' => 'courses',
'tax_query' => array(
 array(
'taxonomy' => 'course_type',
'field' => 'slug',
'terms' => $course_terms, //the taxonomy terms I'd like to dynamically query
'posts_per_page' => '-1'
  ),
),
'orderby' => 'title',
'order' => 'ASC'
) );
if ( have_posts() ): ?>
<ul>
 <?php while (have_posts() ) : the_post(); ?>
  <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?     php the_title(); ?></a></li>
  <?php endwhile; ?>
</ul>
<?php endif;
$wp_query = null;
$wp_query = $original_query;
 wp_reset_postdata(); 
} // end if($terms)