WordPress.org

Ready to get started?Download WordPress

Forums

Adding to the text of each tag - my first attempt at a plugin (1 post)

  1. djschwartz
    Member
    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags