Why is the below code not working?

I am trying to print the selected taxonomies related to the posts in an archive page. The below code works fine but I want to remove the duplicates.

See attached imageScreenshot of the results

How can I achieve this ?

$categories_lists = array();
$category = array();
while ( have_posts() ) : the_post();
    $categories_lists[] = get_the_term_list( $post->ID, 'dt_portfolio_category', '<ul class="styles"><li>', ',</li><li>', '</li></ul>' );

//$unique = array_unique($categories_lists);
foreach($categories_lists as $result)
//echo $result;
$category[] = $result;
$unique = array_unique($category);
foreach($category as $cats)
echo $cats;
//echo $category;
//$a = array_unique($arr);
//echo $arr;

Any help is appreciated.

Read more here: Why is the below code not working?

Leave a Reply

Your email address will not be published. Required fields are marked *