在ACF中继器字段中的“ While”之后显示值

时间:2019-04-25 05:54:18

标签: php wordpress advanced-custom-fields

我试图通过ACF转发器字段ID显示自定义帖子数组。

我只能从$ value中获得一个值,例如:

'post__in'=>数组(905)

但是应该是: 'post__in'=>数组(15,905,1,2,3)

<?php
if( have_rows('take_away_order') ):
while ( have_rows('take_away_order') ) : the_row();
  $value = get_sub_field('food');
?>    
<?php endwhile;?>        
<?php if (is_tax() || is_category() || is_tag() ){
$qobj = $wp_query->get_queried_object();
$args = array(
    'posts_per_page' => 999,
    'post_type' => 'menuu_toit',
    'orderby' => 'menu_order',
    'order'   => 'ASC',
    'post__in' => array($value),
    'tax_query' => array(
        array(
            'taxonomy' => $qobj->taxonomy,
            'field' => 'id',
            'terms' => $qobj->term_id
        )
    )
);
}

1 个答案:

答案 0 :(得分:0)

知道了

 <?php
 if( have_rows('take_away_order') ):
    $value = [];
  while ( have_rows('take_away_order') ) : the_row();

  $value[] = get_sub_field('food');

 ?>    
 <?php endwhile;?>        
 <?php if (is_tax() || is_category() || is_tag() ){
 $qobj = $wp_query->get_queried_object();
 $args = array(
    'posts_per_page' => 999,
    'post_type' => 'menuu_toit',
    'orderby' => 'menu_order',
    'order'   => 'ASC',
    'post__in' => $value,
    'tax_query' => array(
        array(
            'taxonomy' => $qobj->taxonomy,
            'field' => 'id',
            'terms' => $qobj->term_id
        )
    )
 );
 }