How to hide certain tags from the_tags() in WordPress?

I need to assign some tags to my posts (for external use), but I don’t want them showing anywhere that tags are listed. Can someone please give me an example as to how to do this?

Related posts

Leave a Reply

2 comments

  1. this question is very old but i came across this need and i found an interesting solution that i wanted to share.

    It is better to apply a filter to the tags and you won’t be afraid of missing points in your template where you show tags.

    function exclude_tags($tags) {
     foreach ($tags as $tag)
      switch ($tag->name) {
       case 'exclude-this-tag':
       case 'exclude-this-tag-too':
        break;
       default:
        $newtags[] = $tag;
     }
     return $newtags;
    }
    add_filter( 'get_the_tags', 'exclude_tags');
    
  2. Use get_tags() instead of the_tags() in your templates

     $tags = get_tags();
    
     foreach ($tags as $tag)
     {
       if($tag->name=='the tag i want gone') continue;// do this for every tag you want gone
       echo $tag->name.', ';  
     }