Support » Fixing WordPress » How can exclude some tags from ‘the_tags’ list?

  • I want to use ‘the_tags’ to generate a list of a post’s tags, but I need to exclude certain tags from the list.

    How do I do this? I have hunted in the Codex, but can’t find a way to exclude tags.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am having the same problem, did you ever solve this?

    I think this is what you are looking for:

    Excluding Tags from Posts in WordPress

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Or you could add a filter and filter them out entirely…

    function exclude_tags($tags) {
    foreach ($tags as $tag)
    switch ($tag->name) {
     case 'exclude-this-tag':
     case 'exclude-this-tag-too':
      $newtags[] = $tag;
    return $newtags;
    add_filter( 'get_the_tags', 'exclude_tags');

    You guys you’r da mastas’

    Could I modify the Otto’s code (Otto, if reading, how do I modify your code) to exclude, not a compact tag, but an expresion foundable in a tag ?

    Let’s say I have a tag : Lions in The Circus.

    And : Birds in The Circus.

    And I need to exclude every tag where the ‘Circus’ expression is present.

    I know the first solution allows that, but it serves to print a conventional list of tags, when my intention is use the filtered query for another purpose (a customized related posts plugin).

    With a generic function I could get it.
    It must be out there some magical bit of code, some !empty function, or switch, or any of this magical php words which can work it out.

    So please, let’s awake this threat 🙂


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can exclude some tags from ‘the_tags’ list?’ is closed to new replies.