I'd like to show all the taxonomies related to the posts in a category page (archive).
I've the following code
<?php
$cat1 = $cat;
$args = array( 'posts_per_page' => -1, 'category' => $cat1 );?>
$myposts = get_posts( $args );
foreach ( $myposts as $post ) {
$product_terms = wp_get_object_terms($post->ID, 'Brands');
echo '<ul>';
foreach(array_unique($product_terms) as $term) {
echo '<li><a href="'.get_term_link($term->slug, 'Brands').'">'.$term->name.'</a></li>';
}
echo '</ul>';
}
?>
but it returns duplicates for taxonomies. I tried array_unique but it doesn't work. Could you please help. Thanks