I am hoping to make a custom tag widget which displays all tags from a specific category. The code I am currently using is working correctly, but it is displaying duplicate tags. I would like to utilize array_unique()
to remove any duplicates before printing the linked list of tags, but not sure how to pull out the tag slug and tag name after removing duplicates.
Here is my current code:
<?php
query_posts('category_name=testing');
if (have_posts()) : while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo '<a href="' . home_url('/tag/' . $tag -> slug) . '">' . $tag -> name . '</a> ';
}
}
endwhile; endif;
?>