Jump to content

Need help writing a wordpress plugin


cashbagg

Recommended Posts

Hi, I needed a plugin for Wordpress that will automatically add 'http://hornyoyster.com/test/out.php?l=' before any URL I create. This is to track outclicks. It's a pain to enter that manually everytime.

Anyway, asked around and was given this answer:

[i][b]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. [/b][/i]

I interpreted this as:
[i][b]
function adjust_links($content)
{
// http://hornyoyster.com/test/out.php?l=
return $content;
}
add_filter('the_content','adjust_links');

?>[/b][/i]

I uploaded plugin to wordpress and activated it. Did a test post with a link, and my tag did not show. Can anyone steer me right?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.