2016-10-02 91 views
1

我已经创建了自定义字段,并使用WP_Query来输出它们。我有一个“知名度部分”和“信誉部分”,并为ACF插件中的每个设置定制帖子类型。我的知名度部分工作完美,但我需要弄清楚如何将我的信誉帖子类型添加到数组参数,以便我可以在底部输出我的帖子。我不认为我可以再补充其他post_type =>“credibility_section”吧......如何在WP_Query中使用多个post_type?

<?php 
    $args = array(
    'post_type' => 'visibility_section' 
    //Can I add 'post_type' => 'credibility_section' here? 
); 

    $query = new WP_Query($args); 
?> 

<section class="row visibility-content"><!-- Start visibility section --> 
    <div class="container"> 
    <h3 class="text-xs-center m-b-3">Visibility</h3> 
    <div class="col-md-6"> 
    <?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?> 
     <p><?php the_field('visibility_left_column'); ?></p> 
    </div> 
    <div class="col-md-6"> 
     <?php if(get_field('visibility_image')): ?> 
      <img src="<?php the_field('visibility_image'); ?>" /> 
     <?php endif; ?> 
    </div> 
    <div class="col-md-12"> 
     <p><?php the_field('visibility_bottom'); ?></p> 
    </div> 
    <?php endwhile; endif; wp_reset_postdata(); ?> 
    </div> 
</section> 

<section class="row cred-content"><!-- Start Credibility section --> 
    <div class="container"> 
    <h3 class="text-xs-center m-b-3">Credibility</h3> 
    <div class="col-md-12"> 

    </div> 
</section> 

回答

3

可以使用阵列WP_Query参数传递多个post_type

$args = array(
    'post_type' => array('visibility_section', 'credibility_section') 
); 
$query = new WP_Query($args); 


参考:

+0

感谢它帮了我很多... –