Support » Your WordPress » I want to add tag to my links in WordPress

I want to add tag to my links in WordPress

  • I would like to know how to tag every link I create in wordpress. For example, in my post screen, I have a button called ‘link’ which i click on, and enter the hotlink info. Is there a way I can change to wordpress code to always have my link preceded by “http://hornyoyster.com/test/out.php?l=”


Viewing 12 replies - 1 through 12 (of 12 total)
  • You could create a simple plugin to do this sort of thing easily enough. Probably a plugin like this already exists. Try searching around a bit.

    Been searching for a while. no luck yet….

    Well, if you want to roll your own plugin, you need to understand filters.

    A filter receives some text, modifies it, and returns it. So something like this would do the job:

    function adjust_links($content)
    // use regular expressions to modify $content here
    return $content;

    Your function would then be called every time a post is displayed, and it would contain the content of the post. So you could add code to find and modify your links accordingly.

    Samuel B


    Wow Otto – you just saved me a LOT of trouble with an old time client. Thanks so much for your input on this board.
    So easy, also. :>)

    🙁 way out of my league.


    can u specifically tell me how i integrate http://hornyoyster.com/test/out.php?l= before my url’s?

    where do i stick this in the code u posted?

    like this?

    function adjust_links($content)
    // http://hornyoyster.com/test/out.php?l=
    return $content;


    (ps. i created a plugin with this code, and didn;t do anything)

    No, you would need a preg_replace function there to do the adjustment to the content. Something like this:

    function adjust_links($content)
    $content = preg_replace ("href=\"(.*)\"","href=\"http://hornyoyster.com/test/out.php?l=%{1}\"",$content);
    return $content;

    This is just an example. While it may work, it certainly won’t handle every case, and you should really use a better regular expression than my quick attempt. Consult a regex guru.

    bumping old post…still haven’t gotten a solution.




    I use Simple Tagging for my tagging on my blog. I like it a lot, very simple to use, and you can create a tagging cloud on your site as well.

    You can look at my blog for VistaDB for an example of how it works here

    I had a look at that plugin, and I’m not sure it does what I need. (I’m not sure what it does at all actually).

    Can it add my tracking code to every url?



    cashbagg….using the term “tag” confused matters a bit…jasonshortphd is talking about “tagging” and “creating a tag cloud” as a method of grouping similar posts together, using tags, or keywords. The plugin he referred to accomplishes that.

    But you’re looking for a way to prepend affiliate code to all your http links. Quite a different matter. Maybe you should try Googling for a WP plugin designed for affiliate links? I don’t know of one, but there is probably something out there.

    You might also give aLinks a shot. I don’t know if it’s working with 2.1 or 2.2, but it used to be a great way to automatically “linkify” any specific words in your post. It might indirectly accomplish what you’re trying to do, if there is no alternative readily available.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘I want to add tag to my links in WordPress’ is closed to new replies.