The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

add_filter('the_tags', 'myTags'); (4 posts)

  1. DenisCGN
    Posted 4 years ago #


    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,

  2. bcworkz
    Posted 4 years ago #

    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' ;)

  3. DenisCGN
    Posted 4 years ago #

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

  4. bcworkz
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic