我试图通过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
)
)
);
}
答案 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
)
)
);
}