WordPress.org

Support

Support » Plugins and Hacks » Hacks » Adding to the text of each tag – my first attempt at a plugin

Adding to the text of each tag – my first attempt at a plugin

  • I wanted to have my tags show up like this:

    #tagOne #tagTwo

    where the # was automatically added. Instead of hacking the core of WordPress I thought I’d try a quick plugin. I ended up hooking to the “the_tags” filter, and since I was just seeing one big string did a simple replace.

    add_filter('the_tags', 'inject_tag_text');
    function inject_tag_text($content) {
        return str_replace('rel="tag">', 'rel="tag">#', $content);
    }

    This seems pretty fragile to me. It is probably not even close to the best way to make this work, but at the moment it does work. So I’m wondering if I could get any constructive criticism on my first plugin, which was written very quickly around 1am.

    Thanks

  • The topic ‘Adding to the text of each tag – my first attempt at a plugin’ is closed to new replies.