2013-08-16 5 views
5

사용자 지정 분류가있는 사용자 지정 게시 유형을 표시하려고하는데 행운이 없습니다. 아무것도 나타나지 않습니다. 어떤 도움을 주셔서 감사합니다.사용자 지정 분류 WP_Query

포스트 유형 = 갤러리

사용자 정의 분류 슬러그 = photoarea

<?php 

$args = array( 
       'post_type' => 'gallery', 
       'tax_query' => array(
        array(
         'taxonomy' => 'photoarea', 
         'field' => 'fourth', 
         ) 
       ), 
       'posts_per_page' => 10, 
      ); 

$the_query = new WP_Query($args); 


if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 

    the_post_thumbnail(); 

endwhile; endif; 

wp_reset_query(); 

?> 

답변

1

나의 이해가 옳다면

enter image description here 네 번째 I 표시 할 'photoarea'= 그 field 대신 코드를 사용하여 맞춤 분류를 가져와야합니다. 넷째

<?php 

$args = array( 
       'post_type' => 'gallery', 
       'tax_query' => array(
        array(
         'taxonomy' => 'photoarea', 
         'term' => 'fourth', 
         ) 
       ), 
       'posts_per_page' => 10, 
      ); 

$the_query = new WP_Query($args); 


if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 

    the_post_thumbnail(); 

endwhile; endif; 

wp_reset_query(); 

?> 
+0

나를 위해 작동하지 않습니다. 그것은 PHP 통지를 유발합니다. –

+0

'term'이 아니라 'field'=> 'slug'와 'terms'=> 'fourth'이 필요합니다. –

1

를 게시물을 얻을 term을 사용해야합니다 당신은 코드 아래 사용할 수 있습니다 : 다음

$the_query = new WP_Query('post_type=gallery&photoarea=fourth'); 

하고 while 루프를.

-2
$args = array('post_type' => 'gallery','posts_per_page'=>'-1','tax_query' => array(array(
             'taxonomy' => 'photoarea', 
             'field' => 'term_id', 
             'terms' => $your_term_id, 
            ), 
           ), 
          ); 
관련 문제