2016-10-02 1 views
1

私はカスタムフィールドを作成しており、WP_Queryを使って出力しています。私は、ACFプラグインで各設定のカスタム投稿タイプを持つ、 "可視性セクション"と "信頼性セクション"を持っています。私の可視性セクションは完全に動作していますが、私は信頼性ポストタイプを配列引数に追加する方法を理解する必要があります。その結果、その下のセクションに投稿を出力できます。私はあなたがWP_Query引数で配列を使用して複数のpost_typeを渡すことができ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

...私はちょうどそれに別のpost_type =>「credibility_section」を追加することができないと思います。

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


参考:それは私をたくさん助けただ

+0

おかげで... –

関連する問題