我需要获得数组的唯一值,以便在过滤器中使用。这是我的密码
<?php
$newsArgs = array(
\'post_type\' => \'sistemas-sanitarios\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1,
\'post_parent\' => 0,
\'category\' => \'categoria_sistemas_sanitarios\',
\'meta_query\' => array(
array(
\'key\' => \'segmento_produto\',
\'value\' => $linhas[\'id\'],
\'compare\' => \'LIKE\',
)
)
);
$filter_query = new WP_Query( $newsArgs );
?>
<ul id="filters" class="clearfix">
<?php
$taxonomy = \'categoria_sistemas_sanitarios\';
$terms = get_terms( $taxonomy );
echo \'<li><span class="filter-\'. $title . \' active" data-filter="\';
$li = \' \';
foreach ( $terms as $term) {
$li .= \'.\' . $term->slug.\', \';
}
$li = rtrim($li, \', \');
echo $li;
echo \'">Todos os Sistemas</span></li>\';
while ( $filter_query->have_posts() ) : $filter_query->the_post();
$categoria = get_the_terms( $post->ID, \'categoria_sistemas_sanitarios\' );
$categoriaSlug = $categoria[0]->slug;
$categoriaName = $categoria[0]->name;
echo \'<li><span class="filter-\'. $title . \'" data-filter=".\' . $categoriaSlug . \'">\' . $categoriaName . \'</li>\';
endwhile; wp_reset_postdata();
?>
</ul>
我该怎么做?我尝试使用array\\u unique(),但没有成功。
谢谢