2014-09-02 2 views
1

저는 맞춤 게시물 종류 카테고리가 있으며 그 이름은 입니다. 기부금은이고 기부자 카테고리에는 50 개의 게시물이 있습니다. 이제 모든 게시물을 가져오고 싶습니다. 내가 템플릿 페이지에 표시 할맞춤 게시물 유형 특정 맞춤 카테고리 게시물을 표시하려고합니다

는, 이름 /템플릿 이름입니다 : 기부/

도움말 나는이 모든 것을하려고하지만 나를 위해 작동하지 않습니다.

<?php query_posts('category_name=donations&post_type=help'); ?> 

    <?php while(have_posts()): the_post(); ?> 

    <?php the_title(); ?> 

    <?php endwhile; ?> 

<?php wp_reset_query(); ?> 

이 역시 역시 작동하지 않습니다.

<?php $the_query = new WP_Query('category_name=donations&post_type=help'); ?> 

    <?php while($the_query->have_posts()): $the_query->the_post(); ?> 

    <?php the_title(); ?> 

    <?php endwhile; ?> 

<?php wp_reset_postdata(); ?> 

답변

1

시도해보십시오. 택 소노 미 이름을 변경해야 할 수도 있습니다. 방금 당신이 이름을 post_type_category이라고 생각했습니다. 따라서 help이라는 이름을 가진 모든 post_type을 가져오고 post_type_category 이름은 donations입니다.

$args = array('post_type' => 'help', 
       'tax_query' => array(
         array(
         'taxonomy' => 'post_type_category', //don't know if this is right for you 
         'field' => 'slug', 
         'terms' => 'donations' 
        ) 
       ) 
      ); 
$loop = new WP_Query($args); 
while ($loop->have_posts()) : $loop->the_post(); 
    the_title(); 
    echo '<div class="entry-content">'; 
    the_content(); 
    echo '</div>'; 
endwhile; 
+0

정말 감사드립니다. 신은 당신을 축복합니다. –

관련 문제