2014-09-02 50 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。因此,这是让所有post_types与具有post_type_category名为donations名称help

$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

非常感谢你亲爱的。上帝祝福你。 – 2014-09-02 13:36:37

相关问题