2015-02-05 8 views
0

선택 옵션이있는 사용자 정의 게시물 유형이 있습니다. 선택 옵션에서 모든 분류 범주가 있고 선택 항목 변경시 게시물 유형의 모든 게시물이 표시되지만 단일 페이지로 이동하면이 카테고리의 모든 게시물이 아닌 현재 게시물 만 표시됩니다. 나는이 코드를 시도했다 $term = $wp_query->queried_object;하지만이 범주의 현재 게시물 만 표시합니다.현재 보관함 또는 검색어의 모든 게시물에 대한 용어 표시 방법

현재 분류 ​​분류에서 모든 게시물을 가져 오는 방법은 무엇입니까?

답변

-1

는 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) 
이다 내가 가진 것 같다