简体   繁体   中英

Showing value after "While" from ACF repeater field

Im trying to show custom post array by ACF repeater field ID-s.

I only get one value from $value, ex:

'post__in' => array(905)

But it should be: 'post__in' => array(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
        )
    )
);
}

Got it,

 <?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
        )
    )
 );
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM