Support » Fixing WordPress » add_filter('the_tags', 'myTags');

  • Hi,

    I try to strip the following “tag” —> featured

    function myTags($customTags) {
    $customTags = str_replace ('featured', '', $customTags);
    return $customTags;
    add_filter('the_tags', 'myTags');

    This works well, but left a COMMA. When I try to strip “featured,” nothing happens 🙁

    Please can someone help,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    The filter you hooked passes an html list of tags. There is the html close anchor tag ” between ‘featured’ and the comma, that is why ‘featured,’ doesn’t work. If you searched for ‘featured,’ and replaced back in ” it would probably work.

    If you look at your served page source, you will see anchor tags with broken hrefs and no link text. While this works OK, it is a bit sloppy. Just sayin’ 😉

    Thanks for the answer.
    Will there be another filter to exclude the tag “featured”?

    Moderator bcworkz


    I really doubt it, the code just grabs tags, it doesn’t examine what they are.

    I neglected to wrap my html examples in backticks in my previous reply, so they got stripped out, my intent was the text you are trying to extract the ‘featured,’ from actually looks like this:
    You need to search for the whole thing and replace back the closing tag.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add_filter('the_tags', 'myTags');’ is closed to new replies.