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;
}
add_filter('the_content','adjust_links');
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.
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. :>)
otto:
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;
}
add_filter(‘the_content’,’adjust_links’);
?>
(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;
}
add_filter('the_content','adjust_links');
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.
anyone?
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.