【发布时间】:2020-07-07 08:54:37
【问题描述】:
这是我的代码,我得到了重复的值。
$results = array();
$results['targetOptions'] = array();
$selectOptions = array();
$selectOptions = get_posts(
array(
'post_type' => 'collection',
'post_status' => 'publish',
'posts_per_page' => -1,
'post_parent' => 0,
)
);
$results['targetOptions'][] = array("text" => __('Select a Collection', 'theme'), "value" => '');
foreach ($selectOptions as $selectOption) :
if($sourceVal == '999999') {
$terms = get_the_terms( $selectOption->ID, 'window_style' );
}else {
$terms = get_the_terms( $selectOption->ID, 'door_style' );
}
foreach($terms as $term) {
$results['targetOptions'][] = array("text" => $term->name, "value" => 'other-product--' . $selectOption->ID . '--other_product_style--' . $sourceVal);
}
endforeach;
$results['targetClass'] = '.dynamic-collection';
【问题讨论】:
标签: php wordpress advanced-custom-fields custom-taxonomy taxonomy-terms