EDIT
From your comment to your own question, you have two choices if you do not need to apply the filter globally to all instances of get_the_terms)
OPTION 1
Use the same logic as in my ORIGINAL ANSWER
$links = [];
$tags_to_include = [ 1, 2, 3]; // using ID's
foreach (get_the_tags() as $this_tag) {
// If the tag is not in our include list, skip it
if ( !in_array( $this_tag->term_id, $tags_to_include ) ) // Change term_id to name or slug to match $tags_to_include
continue;
// If we are here, our tag is in the list
$links[] = '<a href="'.get_tag_link( $this_tag ).'" title="'.$this_tag->name.'">'.$this_tag->name.'</a>';
}
echo implode(' • ', $links);
OPTION 2
Still use the filter, but remove it when done
First define our call back function
function remove_some_tags( $terms, $post_id, $taxonomy )
{
// Make sure we target only the post_tag taxonomy
if ( 'post_tag' !== $taxonomy )
return $terms;
// Create an array of tags you want to INCLUDE, use tag id's, or slugs or names
$tags_to_include = [ 1, 2, 3]; // using ID's
//$tags_to_include = ['slug-1', 'slug-2', 'slug-3']; // using slugs
//$tags_to_include = ['Name 1', 'Name 2', 'Name 3']; // using names
// Now we can loop through our tags and exclude the one not in our included array
foreach ( $terms as $key=>$term ) {
// Skip tags that appear in the included list
if ( in_array( $term->term_id, $tags_to_include ) ) // Change term_id to name or slug to match $tags_to_include
continue;
// Now we simply unset the tag if we reach this point
unset( $terms[$key] );
} // endforeach
// return the array of tags
return $terms;
}
Now you can do:
// Add our filter
add_filter( 'get_the_terms', 'remove_some_tags' );
$links = [];
foreach (get_the_tags() as $this_tag) {
$links[] = '<a href="'.get_tag_link( $this_tag ).'" title="'.$this_tag->name.'">'.$this_tag->name.'</a>';
}
echo implode(' • ', $links);
// Remove the filter
remove_filter( 'get_the_terms', 'remove_some_tags' );
ORIGINAL ANSWER