nuzzaci External Links; a Wordpress plugin
Background, similar to wikipedia.org, I have a small icon next to all links that will take you away from this site. Up until now I’ve been using a javascript function that I wrote and posted back in December 2006 to find all external links and add the icon. It’s quite a flaky and… ugly script, so I though it would be a good idea to revisit the issue and give it another go.
Thoughts, first I though I would just use the brilliant jQuery javascript library and turn my 10+ lines into 4. This might be a method many would recommend and suggest, but similar to when I approached the “Flickr images are a bit to wide” issue with the nuzzaci Width Watchers plugin, I thought — why not do it server side?
Solution, So, let me present the nuzzaci External Links wordpress plugin. It fairly straight forward.
This plugin will look through your posts before they get displayed and either modify the existing class attribute or create a class attribute with the value external to all links that don’t link within the current domain name. It will ignore all links without http:// and all links where the node is an image. This plugin doesn’t touch the database.
View the script here, and download it here
(the 4 line javascript solution using jQuery can be found here).
Instructions, Download the file, upload it to your plugin folder, log on to your admin section and activate it. Before you see any visual difference on the external links you’ll need to define how you want the class ‘external’ to look like. Here’s an example how you get all external links to look like wikipedia’s external links.
I’m using wordpress 2.0.5, but don’t see why this plugin shouldn’t work on all versions.
Version History
- v 0.1, Launch.

Sweet… :) Kommer att installeras vid flytt.
I just installed it Nico, but doesn’t seem to work on my blog :( I just moved to 2.2 so that’s maybe why? No worries anyhow!
Cookie, you’ll have to add a few lines in your stylesheet (style.css) before you can get a visual difference between external and internal links.
Here’s an example
Thanks for pointing it out, have updated the post to contain this information.
I’m sorry, I’m not sure if I posted this comment already.
I don’t understand where I have to add a few lines in my stylesheet. I’m not a programmer, please can you help me?
Try to locate the style.css file inside you theme and just paste the css at the bottom of the file. Example of CSS can be found if you follow the link in comment #3.
Thanks, that was helpfull.
Some other questions:
1. Can I modify the plugin so my internal links also have an icon (maybe an other icon?)
2. Can I change the colour of the link? With the theme I use, blue isn’t the ideal colour.
Problem n° 1 solved, I deleted:
// Domain name
$domainName = $_SERVER['HTTP_HOST'];
I hope this won’t crash the plugin…
Geert,
If you look at the CSS link to in comment #3, I think you can figure out how to change icon and how to change the color of the link. The hex value after ‘color’ is the color of the link, the url to the wikipidia icon png is the path to the icon. So just change these values with whatever you desire.
If you have further question I would suggest and appreciate if you asked Google instead of me.
Geert,
I can see how deleting that line in the plugin will help you solve anything.