Custom Field Tag filter:
You can try the following code snippet to filter tags from a custom field:
/**
* Support the 'include_tags' custom field (comma seperated tag slugs)
* to filter out those tags to display.
*
* @see http://wordpress.stackexchange.com/a/183929/26350
*/
! is_admin() && add_filter( 'get_the_terms', function( $terms, $post_id, $taxonomy )
{
if( 'post_tag' === $taxonomy
&& ! empty( $terms )
&& $include = get_post_meta( $post_id, 'include_tags', true )
){
// We only want lower case and trimmed strings from the custom meta field:
$include_tags = array_map( 'trim', array_map( 'strtolower', explode( ',', $include ) ) );
// Let's filter out the terms to display:
if( ! empty( $include_tags ) )
$terms = array_filter( $terms, function( $t ) use ( $include_tags ) {
return in_array( $t->slug, $include_tags );
});
}
return $terms;
}, 10, 3 );
For example if you use the_tags()
in your template and have the following tags in a given post:

then you can add the custom field include_tags
with a comma seperated list of tags you want to filter out:

Then it will show like this on your front end:

Similarly we could support exclude_tags
filtering with:
return ! in_array( $t->slug, $include_tags );
instead.