I have a website where I'm showing a list of bookmarks with multiple tags on each one, this is the output:
Bookmark Title
Link
Description text
#tag1 #tag2 #tag3 #tag4 #tag5
Bookmark Title
Link
Description text
#tag3 #tag4
Bookmark Title
Link
Description text
#tag1
(…)
I have a filter where I can select the tags to hide/show the corresponding bookmarks. The problem is now, when there a bookmarks with same tags, the tags also repeating in the filter like:
Filter: #tag1 #tag2 #tag3 #tag4 #tag5 #tag3 #tag4 #tag1
This is my filter:
<div class="d-headline--update__filter">
<?php if( have_rows('bookmark', 'option') ):?>
Filter:
<span class="filter__item filter__all active" onclick="filterSelection('all')">Show all</span>
<?php while( have_rows('bookmark', 'option') ) : the_row();?>
<?php $bookmarkTags = get_sub_field('bookmark_tags', 'option');
if( $bookmarkTags ): ?>
<?php foreach( $bookmarkTags as $bookmarkTag ): ?>
<span onclick="filterSelection('<?php echo $bookmarkTag; ?>')" class="filter__item filter__<?php echo $bookmarkTag; ?>"><?php echo $bookmarkTag; ?></span>
<?php endforeach; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
How can I delete the duplicates in the filter?
$tag1you would see$tag1three times in your filter?